>>I guess what I really need is a better >>understanding of when child control events >>are fired in relation to their parent, >> and if it is possible to change the order >>(ie force the event or control to load).
Best way to find out is to do a few tests on your own. >From my experience and testing, the best I can tell is the events on the page, and the controls contained on the page all fire starting with the parent (the page) and then all the children (order in which the children fire events is not guaranteed). For example, the page will call initialize, followed by the controls calling initialize. Next the LoadViewState method will be called on the page, followed by the controls contained in the Page class. Following along in that manner until the Render method is called. Like this Page.Init Child1.Init Page.LoadViewState Child1.LoadViewState . . . Page.Render Child1.Render The one exception to this is when you add controls to the page dynamically. If you dynamically place a checkbox on the parent control when the parent already at the "Load" event, the checkbox will be syncronized with the rest of the controls on the page. i.e. all the events up to and including the load event on the checkbox will fire. You get results more like this Page.Init Child1.Init Page.LoadViewState Child1.LoadViewState ... Page.Load Child1.Load Checkbox.Init Checkbox.LoadViewState Checkbox.LoadPostbackData Checkbox.Load ... Page.Render Child1.Render Checkbox.Load Hope this helps. You can find more info on these events and the order in which they are fired if you search in MSDN using the keywords "Control Execution Lifecycle". Ben Coverston [EMAIL PROTECTED] 651.442.3488 -----Original Message----- From: Andrew Davey [mailto:[EMAIL PROTECTED]] Sent: Monday, August 12, 2002 8:50 PM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Forcing the Page_Load event on a custom child control The controls on the page are in the HTML side and are not added (by myself) to the controls collection after the page has started loading. >From what I read in the MSDN documentation, I thought the event sequence would be as you said. I kind of fixed my problem by setting the properties of the child controls during the parent controls RenderChildren method. However this is less than ideal as it works fine in this instance, but I have another situation with another control where a property is best set before the child controls Page_Load event. I guess what I really need is a better understanding of when child control events are fired in relation to their parent, and if it is possible to change the order (ie force the event or control to load). Does you or anyone else know the proper order or where I can find out? TIA Andy You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.
