From my ASP.NET experience, understanding the Page Lifecycle and what occurs at each point is one of the most confusing (and important) aspects of ASP.NET development.
There is also several pages in my Microsoft Press book that are very similar to these MSDN pages.
The challenge is remembering each of the events, and what is appropriate to do at that particular event. For example:
- PreInit - Set Master Page, Set Theme, create dynamic controls
- Init - Controls have been initialized, theme skins applied. Initialize control properties.
- InitComplete - Perform tasks that require initialization has been completed.
- PreLoad - Perform any processing that should occur before Load.
- Load - Set properties in controls and establish database connections
- Control Events (calling of delegates based on events raised, should check Page.IsValid if there are any Validator controls).
- LoadComplete - Perform tasks that require load has been completed.
- PreRender - Prior to this event occurring, Page calls EnsureChildControls for all controls, including itself. Also, all data bound controls have DataBind method called.
- SaveStateComplete - ViewState has been encoded and saved, then this event occurs.
- Render - Page object calls Render on every control.
- Unload - event occurs for each Control, finally for the Page. Do cleanup, close database connections.
No comments:
Post a Comment