Dynamic Controls in User Control; page/control lifecycle question

F

Frankie

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.
 
F

Frankie

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top