The blog has moved to the new site F10Debug.com

Friday, April 1, 2011

Event/Page Life cycle in asp.net


Event Life cycle of ASP.NET 2.0

To track the flowing of events in web application, you need to add “trace = true” in page directive as shown below.
       <% @Page Trace=”true”%>
PreInit
1)    Entry point of page life cycle.
2)    We can create or re-create dynamic controls.
3)    We can change master page dynamically.
4)    We can change theme properties dynamically in this control.
Init -
1)    All Control are initialized in this event
2)    The init event of each controls occurs first then init event for page occurs.

Init Complete –
1)    Page is initialized.
2)    Use this event to make changes in view state that you want to make sure are affected after the next post back.

PreLoad
1)    This event is called before the loading of the page is completed. 

Load
1)    This event is raised for the Page first and then for all child controls.
2)    The view state can be accessed at this stage.
3)    This event indicates that the controls have been fully loaded.

LoadComplete -
1) This event signals indicates that the page has been loaded in the memory.
2) It also marks the beginning of the rendering stage.

PreRender
1)    If you need to make any final updates to the contents of the controls or the page, then use this event. 
2)    It first fires for the page and then for all the controls.

PreRenderComplete
         1) Is called to explicitly state that the PreRender phase is completed. 

SaveStateComplete
1)   In this event, the current state of the control is completely saved to the ViewState.
                  
Unload
                  1)  This event is typically used for closing files and database connections.


Stages and corresponding events in the life cycle of the ASP.NET page cycle:

 
Stage
Events/Method
Page Initialization
Page_Init
View State Loading
LoadViewState
Postback data processing
LoadPostData
Page Loading
Page_Load
PostBack Change Notification
RaisePostDataChangedEvent
PostBack Event Handling
RaisePostBackEvent
Page Pre Rendering Phase
Page_PreRender
View State Saving
SaveViewState
Page Rendering
Page_Render
Page Unloading
Page_UnLoad

No comments:

Post a Comment