Change event sequence

  • Thread starter Thread starter Redhairs
  • Start date Start date
R

Redhairs

I created two base page class and a webform to inherit them as blow.

Public Class BasePage:System.Web.UI.Page
{
protected override void OnPreInit(EventArgs e)
{ base.OnPreInit(e); }
}


Public Class ContentPage : BasePage
{
protected override void OnPreInit(EventArgs e)
{ base.OnPreInit(e); }
}

WebForm.aspx inherit theContentPage class

Then the event execution order is the Page_PreInit() ->
BasePage.OnPreInit() -> ContentPage.OnPreInit()
How to change the execution sequence as below?
(1) ContentPage.OnPreInit()
(2) BasePage.OnPreInit()
(3) Page_PreInit()
 
its all an when you call the base routine try:

Public Class BasePage:System.Web.UI.Page
{
protected override void OnPreInit(EventArgs e)
{
// do base page stuff

base.OnPreInit(e); // fires Page_PreInit()
}
}


Public Class ContentPage : BasePage
{
protected override void OnPreInit(EventArgs e)
{
// do content stuff here

base.OnPreInit(e); // fire basepage
}
}

-- bruce (sqlwork.com)
 
Back
Top