Home All Groups Group Topic Archive Search About

Control events - page life-cycle

Author
20 Sep 2006 2:29 PM
Griff
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

Author
20 Sep 2006 3:01 PM
Cowboy (Gregory A. Beamer)
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!
*************************************************
Show quoteHide quote
"Griff" <howl***@the.moon> wrote in message
news:%23RYLsEM3GHA.2096@TK2MSFTNGP05.phx.gbl...
>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
>
>
>
Author
20 Sep 2006 3:11 PM
Griff
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


Show quoteHide quote
"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@comcast.netNoSpamM> wrote in
message news:uG0GnWM3GHA.1796@TK2MSFTNGP06.phx.gbl...
> 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.
Author
20 Sep 2006 4:13 PM
Griff
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



Show quoteHide quote
"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@comcast.netNoSpamM> wrote in
message news:uG0GnWM3GHA.1796@TK2MSFTNGP06.phx.gbl...
> 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.