Change event sequence

Discussion in 'ASP .Net' started by Redhairs, Jan 10, 2008.

  1. Redhairs

    Redhairs Guest

    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()
     
    Redhairs, Jan 10, 2008
    #1
    1. Advertising

  2. Redhairs

    bruce barker Guest

    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()
    >
    >
    >
     
    bruce barker, Jan 10, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guadala Harry

    PostBack Event Firing Sequence

    Guadala Harry, Aug 15, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    4,094
    Bredal Jensen
    Aug 15, 2004
  2. Josh

    Event Sequence Wrong

    Josh, Aug 17, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    428
    Eliyahu Goldin
    Aug 17, 2005
  3. =?Utf-8?B?SmF5?=
    Replies:
    3
    Views:
    975
    Kevin Spencer
    Dec 21, 2005
  4. Phillip N Rounds

    Question re Event Firing Sequence

    Phillip N Rounds, Mar 1, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    411
    Eliyahu Goldin
    Mar 5, 2006
  5. stef mientki
    Replies:
    13
    Views:
    694
    stef mientki
    Oct 20, 2007
Loading...

Share This Page