Change event sequence
am 10.01.2008 20:30:53 von redhair
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()
RE: Change event sequence
am 10.01.2008 21:23:02 von brucebarker
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)
"Redhairs" wrote:
> 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()
>
>
>