Materpage page_load event fired after content page_load?

Discussion in 'ASP .Net' started by rockdale, Nov 16, 2006.

  1. rockdale

    rockdale Guest

    Hi,

    I have a masterpage and on the page_load event I Populate my mainmenu
    from database.

    I the page_load event of my content, I am trying to programmly select
    the menuitem that represent current content page, but as you know, the
    page_load event is fired backward, the content page_load fires first
    then followed by the master page page_load, I could not get the
    mainmenu in the content page( have not been initialized since
    masterpage's page_load have not been fired).

    Is there a way to workaround? e.g. put the programmly select menuitem
    into another event instead in page_load?


    attached is my pseudocode:

    MasterPages


    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsPostBack)
    {
    PopulateMainMenu();
    }
    }


    Content Page
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsPostBack)
    {

    Menu mMain = (Menu)this.Master.FindControl("menuMain");
    mMain.Items[0].Selected = true;

    }
    }




    Thanks a lot
    -rockdale
     
    rockdale, Nov 16, 2006
    #1
    1. Advertising

  2. How about using the Init event. Since the MasterPage is really a child
    control inside the content page, it's Init eventhandler will fire before the
    Page's Init eventhandler.
    Peter

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "rockdale" wrote:

    > Hi,
    >
    > I have a masterpage and on the page_load event I Populate my mainmenu
    > from database.
    >
    > I the page_load event of my content, I am trying to programmly select
    > the menuitem that represent current content page, but as you know, the
    > page_load event is fired backward, the content page_load fires first
    > then followed by the master page page_load, I could not get the
    > mainmenu in the content page( have not been initialized since
    > masterpage's page_load have not been fired).
    >
    > Is there a way to workaround? e.g. put the programmly select menuitem
    > into another event instead in page_load?
    >
    >
    > attached is my pseudocode:
    >
    > MasterPages
    >
    >
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > if (!Page.IsPostBack)
    > {
    > PopulateMainMenu();
    > }
    > }
    >
    >
    > Content Page
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > if (!Page.IsPostBack)
    > {
    >
    > Menu mMain = (Menu)this.Master.FindControl("menuMain");
    > mMain.Items[0].Selected = true;
    >
    > }
    > }
    >
    >
    >
    >
    > Thanks a lot
    > -rockdale
    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Nov 16, 2006
    #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. Steven K
    Replies:
    0
    Views:
    435
    Steven K
    Sep 23, 2004
  2. Michal Kostic via .NET 247

    Page_load not fired after some time of inactivity

    Michal Kostic via .NET 247, May 24, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    528
    Hans Kesting
    May 24, 2005
  3. =?Utf-8?B?YmVycnkubW9yZ2Fu?=

    HOWTO determine in content page page_load if masterpage fired post

    =?Utf-8?B?YmVycnkubW9yZ2Fu?=, Apr 17, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    477
    =?Utf-8?B?YmVycnkubW9yZ2Fu?=
    Apr 17, 2007
  4. =?Utf-8?B?Yl9hc3AubmV0?=
    Replies:
    0
    Views:
    353
    =?Utf-8?B?Yl9hc3AubmV0?=
    Apr 18, 2007
  5. Richard Murphy
    Replies:
    0
    Views:
    169
    Richard Murphy
    Aug 7, 2003
Loading...

Share This Page