Inheritance in 2.0

D

David Lozzi

Howdy,

How does one go about inheriting a class? Specifically at the page level?
I'm new to .Net 2.0 and never used inheritance before in .Net 1. I've been
reading on the error handling and the book I read suggested to use the
Page_Error event to handle exceptions then send the user to a generic page.
That part I get, then it said to simply inherit this class in all pages.
That's where I'm stuck. So, i want to inherit page level exception handling
into my pages from a class. How? One other thing, if I throw the page
handling in my master page, will that capture errors from the referenced
content pages?

Thanks!

David Lozzi
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

David said:
Howdy,

How does one go about inheriting a class? Specifically at the page level?
I'm new to .Net 2.0 and never used inheritance before in .Net 1. I've been
reading on the error handling and the book I read suggested to use the
Page_Error event to handle exceptions then send the user to a generic page.
That part I get, then it said to simply inherit this class in all pages.
That's where I'm stuck. So, i want to inherit page level exception handling
into my pages from a class. How?

Say that you have your page class with error handling:

class ErrorHandlerPage : Page {

To inherit the class in a page, simply change:

class AnyPage : Page {

to:

class AnyPage : ErrorHandlerPage {
One other thing, if I throw the page
handling in my master page, will that capture errors from the referenced
content pages?

If you mean that you want to handle the Error event in the master page,
then no. The MasterPage class has no Error event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top