you have it slightly wrong. onload fires after all controls defined on page
have been created and their data loaded from the postback data if any.
browser requests page ->>
server
OnInit
OnLoad (form load)
OnPreRender
SaveViewState
Render
OnUnload
<<-- rendered page sent to browser
browser loads page
user clicks on something to do postback
browser posts form data --->
server
OnInit
LoadViewState
LoadPostBackData (loads controls with postback data)
OnLoad (form load)
RaisePostDataChangedEvent (controls raise data change event here)
RaisePostBackEvent (controls raise postback events here)
OnPreRender
SaveViewState
Render
OnUnload
<<-- rendered page sent to browser
browser loads page
you can see from the page create cycle, that OnInit is the last chance to
create dynamic controls that load postback data. OnPreRender is the last
chance to add/change controls that will actually render.
-- bruce (sqlwork.com)
"Matthew Louden" <ma*******@hotmail.com> wrote in message
news:e$**************@TK2MSFTNGP12.phx.gbl...
I created simple ASP.NET web application to test how AutoPostBack property
in a web control works.
I set AutoPostBack property to be true of a web control. When I run the
application, here's the sequences when I step through the program:
1. Page loaded to the browser
2. Page_Load method is called with non-postback event
3. The user has certain actions on a control
4. Page_Load method is called with postback event
5. A control's event handler is called.
My question is why Page_Load method is called before a control's event
handler? i.e. Should step 4 and step 5 be reversed in order?
My understanding is ONE CONTROL EVENT causes ONE POSTBACK. Event is the
cause, and PostBack is the result. Am I wrong?? Thats why I think a
control's event handler should call first before Page_Load method.
Please advise. Thanks!
`