Control events - page life-cycle

Discussion in 'ASP .Net Web Controls' started by Griff, Sep 20, 2006.

  1. Griff

    Griff Guest

    I want to build a set of compiled user controls to incorporate into a web
    site.

    The majority of user controls will be placed on specific web page and these
    controls would share a common interface. The interface would expect some
    sort of "end user identitifier" argument, perhaps a GUID.

    I thought that this user identifier GUID could be generated by a common user
    control (either from state information held on the client cookies, or in the
    database or where-ever...). This common control would therefore be best
    placed on a master page that was inherited by all the web pages.

    The problem is of course the event life cycle...
    1. Default Page's Control's Page_Init()
    2. Master Page's Control's Page_Init()
    3. Master Page's Page_Init()
    4. Default Page's Page_Init()
    5. Default Page's Page_Load()
    6. Master Page's Page_Load()
    7. Default Page's Control's Page_Load()
    8. Master Page's Control's Page_Load()

    I'd obviously require the common control (on the master page) to fire BEFORE
    the specific control on the page....and this won't happen.

    I'm sure that this is a common problem, but am having a hard time finding a
    suitable work-around. Any help most appreciated.

    Thanks

    Griff
    Griff, Sep 20, 2006
    #1
    1. Advertising

  2. Here is an option: Set up a property on the control in question and use the
    property load to set the control to the state you desire.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    *************************************************
    Think outside of the box!
    *************************************************
    "Griff" <> wrote in message
    news:%...
    >I want to build a set of compiled user controls to incorporate into a web
    >site.
    >
    > The majority of user controls will be placed on specific web page and
    > these controls would share a common interface. The interface would expect
    > some sort of "end user identitifier" argument, perhaps a GUID.
    >
    > I thought that this user identifier GUID could be generated by a common
    > user control (either from state information held on the client cookies, or
    > in the database or where-ever...). This common control would therefore be
    > best placed on a master page that was inherited by all the web pages.
    >
    > The problem is of course the event life cycle...
    > 1. Default Page's Control's Page_Init()
    > 2. Master Page's Control's Page_Init()
    > 3. Master Page's Page_Init()
    > 4. Default Page's Page_Init()
    > 5. Default Page's Page_Load()
    > 6. Master Page's Page_Load()
    > 7. Default Page's Control's Page_Load()
    > 8. Master Page's Control's Page_Load()
    >
    > I'd obviously require the common control (on the master page) to fire
    > BEFORE the specific control on the page....and this won't happen.
    >
    > I'm sure that this is a common problem, but am having a hard time finding
    > a suitable work-around. Any help most appreciated.
    >
    > Thanks
    >
    > Griff
    >
    >
    >
    Cowboy \(Gregory A. Beamer\), Sep 20, 2006
    #2
    1. Advertising

  3. Griff

    Griff Guest

    Hi Gregory

    So, just thinking this through, the following steps would need to occur in
    sequence

    In the web page load event
    1 - WebPage.UserControl.UserID = MasterPage.UserControl.GetUserGuid()
    2 - WebPage.UserControl.GenerateOutput()

    Yup - think that would work....thanks

    Griff


    "Cowboy (Gregory A. Beamer)" <> wrote in
    message news:...
    > Here is an option: Set up a property on the control in question and use
    > the property load to set the control to the state you desire.
    Griff, Sep 20, 2006
    #3
  4. Griff

    Griff Guest

    Hi Gregory

    I seem to have hit a bit of a stumbling block....

    I want the Master Page's control to generate a GUID that identifies the end
    user. This will be on a Master page because I want it on EVERY web page. I
    presume that the earliest that this function could be called would be AFTER
    the Master Page's Control's Page_Load() event has been fired.

    I then want the web page's Control to take in this GUID and then, based on
    some business logic, load another specific User Control at run time. Using
    the MVC model, it's a way of saying that the View used by every control is
    dependent upon the user calling it.

    But it appears that the event order prevents this....

    Griff



    "Cowboy (Gregory A. Beamer)" <> wrote in
    message news:...
    > Here is an option: Set up a property on the control in question and use
    > the property load to set the control to the state you desire.
    Griff, Sep 20, 2006
    #4
    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. =?Utf-8?B?TG91aXMtUGhpbGlwcGUgRHVtb3VsaW4=?=

    ajax postback causing Page reload after normal events life cycle

    =?Utf-8?B?TG91aXMtUGhpbGlwcGUgRHVtb3VsaW4=?=, Mar 14, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    4,325
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Mar 14, 2006
  2. Griff

    Control events - page life-cycle

    Griff, Sep 20, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    911
    Griff
    Sep 20, 2006
  3. lander
    Replies:
    5
    Views:
    2,518
    Mark Rae [MVP]
    Mar 3, 2008
  4. bogdan
    Replies:
    1
    Views:
    2,382
    Teemu Keiski
    Mar 20, 2008
  5. TS
    Replies:
    5
    Views:
    851
Loading...

Share This Page