Menu ▼

Previous Next

ASP.NET Page life cycle:

ASP.NET Page life cycle having different stages and in each stage there are different events, which are having a sequence of flow. i.e. each stage or event will fire one after one in an ordered manor, each and every developer should have a basic knowledge on flow of the Page life cycle then only one can write our code in more poper way.

Events :

  • PreInit
  • Init
  • InitComplete
  • PreLoad
  • Load
  • Control Events (Post back events)
  • LoadComplete
  • PreRender
  • PreRenderComplete
  • SaveStateComplete
  • Render
  • Unload

PreInit :
The first event in Page life cycle, In this event if any value assigned to the controls that may overwritter because in the InIt event controls value will be restored from view state. Prefer this event to creating or re-creating dynamic controls.

Init :
First this event will be raised for each control , then finally Init event for page will be raised. Prefer this event to set control properites.

InitComplete :
View state will be saved persistently in this event,In this event any changes done in viewstate that will be available even in next postback.

PreLoad :
The post back data that is included with the request instance will be processed.

Load :
First this event will be raised for page then it will be raised for all controls in the page. Use this event to set the control default values, binding dropdown list and other when first time page loads (if not postback).

Control Events (Post back events) :
After page load, the specific control post back events will be fired. (ex : button click, dropdown selectedindexchanged, gridview pageindexchanged, textbox textchanged,...)

LoadComplete :
This event will be raised after Control events and before PreRender event.

PreRender :
PreRender event will be first raised for the Page, then it will raise for all the controls in the page. Any final modification on the control values you want to perform has to be done at least here, after this event if you done any changes for the control values it will affect rendaring but not be retrived in the next postback.

PreRenderComplete :
Raises for each control and page after it's PreRender event completed.

SaveStateComplete :
This event will be raised after the viewstate and control state have been saved for the page and all controls.

Render :
Render is a method, not event. you can over ride this method to change the output of the control markup.

Unload :
This event will first raises for each control then finally for page.

Previous Next




Search dotnetlearners.com