Inherit Page_Load method

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have some repeated code in the Page_Load() methods in several asp.net pages. This common code performs some checking and is not related to HTML.

I tried to create a Base asp.net page containing this common code in the Page_Load() and the other asp.net pages inherit this base page and ovverride this method. The problem is that only the code in the base page is being excecuted.

Any ideas?

Chris
 
Christopher Attard said:
Hi,
I have some repeated code in the Page_Load() methods in several
asp.net pages. This common code performs some checking and is not related to
HTML.
I tried to create a Base asp.net page containing this common code in the
Page_Load() and the other asp.net pages inherit this base page and ovverride
this method. The problem is that only the code in the base page is being
excecuted.
Any ideas?

Chris

How did you override the method from the base class?
How did you attach the method to the Load event?


It should be something like:

protected override void Page_Load(...)
{
base.Page_Load(...);
....
}

where this Page_Load is attached to the Load event of this page.


Hans Kesting
 
yeah ok 10x. Infact it's actually running the base page and the page's Page_Load() method.

Now the problem is that it's not handling the other events. For eg: In asp.net page1 (which inherits the base page) I have 2 buttons. Their event handlers are imnplemented and also registered in page1 but they are not working

Each of these pages contains different events so I can neither put them in the base class. What else can be done

Chri
 
Back
Top