ASP.Net Page Life cycle - DotNet and DataBase

Follow us on Facebook

SQL Server Mountain View Mountain View Mountain View

Wednesday, 15 August 2018

ASP.Net Page Life cycle

In the ASP.Net page, when the page is called and render the data to the user browser, some events will be occurred, which are called as ASP.Net lifecycle events.

They are

  1. Initialization
  2. Load
  3. Render
  4. Unload
Initialization could happen in 3 stages.

PreInit, Init, and InitComplete
IsPostBack, IsCallBack and IsCrossPostBack properties are set at this stage. This event allows us to set the master page and theme of the web page dynamically. This could be more useful when we are working with dynamic web pages.

protected void Page_PreInit(object sender, EventArgs e)

This event is to set or initialize the control properties. Server controls get the initialization or load using View state on this event. 

   protected void Page_Init(object sender, EventArgs e)


Raised at the end of the page's initialization event. Only one action takes place between the Init and InitComplete events.  Identification of view state changes is turned on. View state tracking enables controls to persist any values that are programmatically added to the ViewState collection. Until view state tracking is turned on, any values added to view state are lost across postbacks. Controls typically turn on view state tracking immediately after they raise their Init event. 

protected void Page_InitComplete(object sender, EventArgs e)

The Load has three events.

PreLoad, Load, and Load complete.


This event is occurs before the postback(ViewState) data is loaded into the controls. We can make control property changes in the stage.

protected override void OnPreLoad(EventArgs e )        


This event is raised for the page first time and then repeatedly for all controls exist in the page.

protected void Page_Load(object sender, EventArgs e)


This event raises after the control events are handled

   protected void Page_LoadComplete (object sender, EventArgs e)


This event occurs after the page object has created and all controls that are required in order to render the page.

  protected override void OnPreRender(EventArgs e)


No comments:

Post a comment


Get Updates On

Discussion updates

Straight Into Your INBOX!

Enter your email address to subscribe to this website and receive notifications of new posts by email.