Showing posts with label life cycle. Show all posts
Showing posts with label life cycle. Show all posts

Saturday, February 15, 2014

ASP PAGE LIFE CYCLE

ASP PAGE LIFE CYCLE

Introduction:

     The life cycle of an asp.net page can be understandable easily if you have a knowledge of some keywords like viewstate, postback and events in asp.net . 

Description:

PreInit -

* In preinit you can check weather the page is loaded first time             or  not using IsPostBack property.
* On the first time load page you can create control with values.
* You can set master page and theme dynamically.

* If the page is postback, you can set control property value to           be overwritten. 
 * The values have not been yet restored from viewstate.
     
Init -

* In the Init event of the individual controls occurs first, later               the Init event of the Page takes place.
 * This event is used to initialize control properties.

InitComplete -

* In the InitComplete event the viewstate property checking will be done and that changes will be persisted until next postback.

PreLoad -
* This will process the data on postback event with the request.

Load -
* In this process the initial Page controls or objects calls the OnLoad method and that method with any controls or objects comes next.

ControlEvents -

* This events occurs after page loads like onclick in button, textchanged in textbox, onchange in dropdownlist etc.

In case of the postback, 
if the page contains validator controls , the page.isvalid property and the validation of the control takes place before the firing of individual events.

Load Complete - 

* This session occurs after the event handling page.
* This will complete all controls and their methos events.

Pre Render -

* This method is used to make final changes to the controls on the page like assigning the DataSourceId and calling the DataBind method.

PreRenderComplete -

* This event is raised after all the final id values are set in prerender completes.

SaveStateComplete -

* This will occur after control state and view state saved.

RenderComplete -

* This method writes the controls values or markup to the browser.

Unload -

* This event is raised for each control and then for the page.

* This will do the final clean up work and close dataconnection etc.,

If any clarification or need changes please comment.
Thank you!