Sunday, June 24
ASP.Net Page Cycle
Understanding the ASP.Net page cycle is important and helpful in cases where you need to make changes to a control/ add a conrol/ change the master page at runtime, etc..
Here is the sequence of events and a brief description of the critical ones. I haven't had the chance to use of all of them as yet.
Order top to bottom
PreInit (method: Page_PreInit)
InitComplete
PreLoad
Load
LoadComplete
PreRender
PreRenderComplete
Render
UnLoad
Here is the sequence of events and a brief description of the critical ones. I haven't had the chance to use of all of them as yet.
Order top to bottom
PreInit (method: Page_PreInit)
InitThemes and master pages are applied between PreInit and Init, hence PreInit is the last place to programtically modify the selected theme/masterpage. When implmenting "Nested Master pages" while maintaining the ability to see pages in design mode in VS 2005, one needs to set the the change the page's current master page ( the base master page) to the nested master page using this event.
This event is called before any state is restored from the
client response. It is used to prepare the Page for processing the request. Dynamic controls can be added in this event.
Child controls are created between this event and the "InitComplete" event if it is a postback. Also, Control/View State is loaded if it is a postback.
Load
Most commonly used event. It is used to initialize control values on a GET request (!IsPostBack). It is called after
the control/view state has been restored in the Init event on a POST request (IsPostBack) before control passes to the specific event that caused the postback.
To be used to move code from the PreRender event,
the place to make last minute changes to controls.
Used to make any post-event modifications to the controls (Last place to make a change before they get rendered). Recently, I created an editable gridview consiting of 2 columns, one a "State" dropdown and the other "Type" dropdown whose content needed to be changed based on the state selected. I had a Telerik RadAjaxPanel around the Grid and wanted to change the content of the "type" dropdown based on the selection in the "State" dropdown. I had specifically used the PreRender event to tie the "State" dropdown to the "Type" dropdown for every row in the Grid.
Render
UnLoad
Subscribe to Posts [Atom]