Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Dynamic Controls in User Control; page/control lifecycle question (http://www.velocityreviews.com/forums/t105192-dynamic-controls-in-user-control-page-control-lifecycle-question.html)

Frankie 06-22-2005 08:17 PM

Dynamic Controls in User Control; page/control lifecycle question
 
I have a user control into which I insert a bunch of controls dynamically. I
have it all working just fine - Everything is there on Postback, etc.

I load this user control into a hosting ASPX page at runtime during the
Page_Load event procedure of the hosting ASPX page.

Question: Would it be better to load the user control from the hosting
page's OnInit event rather than Page_Load? Does it matter or not?

I ask because I understand that for dynamic controls to be properly
inserted - it must be done during the OnInit event - which is happening -
but only in the ASCX lifecycle (which gets kicked off from the hosting aspx
page_load).

Thanks.



Kevin Spencer 06-23-2005 11:30 AM

Re: Dynamic Controls in User Control; page/control lifecycle question
 
Hi Frankie,

The following >Net SDK article on Control Execution Lifecycle should clear
everything up for you. I keep a print-out of it on my office wall!

http://msdn.microsoft.com/library/de...nLifecycle.asp

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Frankie" <A@B.COM> wrote in message
news:%23XwL2d2dFHA.2776@TK2MSFTNGP10.phx.gbl...
>I have a user control into which I insert a bunch of controls dynamically.
>I have it all working just fine - Everything is there on Postback, etc.
>
> I load this user control into a hosting ASPX page at runtime during the
> Page_Load event procedure of the hosting ASPX page.
>
> Question: Would it be better to load the user control from the hosting
> page's OnInit event rather than Page_Load? Does it matter or not?
>
> I ask because I understand that for dynamic controls to be properly
> inserted - it must be done during the OnInit event - which is happening -
> but only in the ASCX lifecycle (which gets kicked off from the hosting
> aspx page_load).
>
> Thanks.
>




Frankie 06-23-2005 04:07 PM

Re: Dynamic Controls in User Control; page/control lifecycle question
 
Thanks Keven - great little article. Based on the following statements in
the article...

"a control is unable to invoke its parent until the tree of controls on a
page has been populated"
and
"CreateChildControls can be invoked when loading a page, during data
binding, or during rendering"

.... I'm concluding that the scenario I have created (as described in the OP)
is just fine - if not what must happen. If I'm totally wrong about that,
then please let me know - otherwise have a great day!

-Frankie



"Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
news:eiEi2b%23dFHA.612@TK2MSFTNGP12.phx.gbl...
> Hi Frankie,
>
> The following >Net SDK article on Control Execution Lifecycle should clear
> everything up for you. I keep a print-out of it on my office wall!
>
> http://msdn.microsoft.com/library/de...nLifecycle.asp
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> Ambiguity has a certain quality to it.
>
> "Frankie" <A@B.COM> wrote in message
> news:%23XwL2d2dFHA.2776@TK2MSFTNGP10.phx.gbl...
>>I have a user control into which I insert a bunch of controls dynamically.
>>I have it all working just fine - Everything is there on Postback, etc.
>>
>> I load this user control into a hosting ASPX page at runtime during the
>> Page_Load event procedure of the hosting ASPX page.
>>
>> Question: Would it be better to load the user control from the hosting
>> page's OnInit event rather than Page_Load? Does it matter or not?
>>
>> I ask because I understand that for dynamic controls to be properly
>> inserted - it must be done during the OnInit event - which is happening -
>> but only in the ASCX lifecycle (which gets kicked off from the hosting
>> aspx page_load).
>>
>> Thanks.
>>

>
>





All times are GMT. The time now is 02:06 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.