Change event sequence

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()
 
B

bruce barker

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)
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top