Page Life Cycle Events

-> When a page request is sent to the Web server, the page is run through a series of events during its creation and disposal.

-> PreInit
-> Init (View State Restoration)
-> InitComplete
-> PreLoad
-> Load
-> Control Events
-> Load Complete
-> PreRender
-> PreRenderComplete
-> SaveStateComplete
-> Unload
-> Error

PreInit
-> Use this event for the following:
-> Check the IsPostBack property to determine whether this is the first time the page is being processed.
-> Create or re-create dynamic controls.
-> Set a mater page dynamically.
-> Set the theme property dynamically.
-> If the request is a postback, the values of the controls have not yet been restored from view state. If you set a control property at this stage, its value might be overwritten in the next event.

Init
-> Raised after all controls have been initialized and any skin settings have been applied. Use this event to read or initialize control properties. The init event is fired first for the most bottom control in the hierarchy, and then fired up the hierarchy until it is fired for the page itself.

InitComplete
-> Use this event for processing tasks that require all initialization be complete.

PreLoad
-> Use this event if we need to perform processing on page or control before the load event. After the page raises this event, it loads view state for itself and all controls, and then processes any postback data included with the Request instance.
-> Loads Viewstate : ViewState data are loaded to controls.
-> Loads Postback data : Postback data are now handed to the page controls.

Load
-> The page calls the OnLoad event method on the Page, then recursively does the same for each child control, which does the same for each of its child controls until the page and all controls and then processes any postback data included with the Request instance.

Control Events (PostBack events)
-> Use these events to handle specific control events, such as Button control’s click event or a Textbox Control’s TextChanged event.
-> ASP.Net now calls any events on the page or its controls that caused the Postback to occur.

LoadComplete

PreRender

PreRenderComplete

SaveStateComplete

Render

Unload

Leave a Reply

Your email address will not be published. Required fields are marked *