For this test, I created a new web project inVS2008 and simply added a server button on the aspx form, with a bunch of Response.writes in each event I found in the code behind, except inside the unload events, as a Response.write in the unload event will cause a runtime error to occur.
The result of this quick test is as follows:
- New
- Page PreInit
- button Init
- form Init
- page Init
- Page InitComplete
- Load Viewstate *
- Page Preload
- Page Load
- form Load
- button Load
- Button Click ^
- Button Command ^
- Page LoadComplete
- Page PreRender
- form PreRender
- button PreRender
- page PreRenderComplete
- page SaveStateComplete
- button Unload
- form Unload
- page Unload
If Not Page.IsPostBack Then
Me.ViewState("x") = "x"
End If
I then monitored when the variable x in the view state changed from nothing to x using Watch after clicking on the button.
^ these events were fired after a page postback.
As you can see, the viewstate is loaded after the page init event, but before the page load event. This is very important to remember if you are planning to work with viewstates in aspx.
Also, note that postback events (eg. button Click), occur after page Load, but before the page LoadComplete events.
No comments:
Post a Comment