Page Life Cycle — ASP.NET

Soumya Patil
2 min readFeb 3, 2020

--

Whenever a client requests an asp.net page it goes through a series of events on the server-side which will allow a page to be created. These events take place in a sequential manner.

In the current version of the page life cycle, there are 12 events:

Page Life Cycle

PerInit :

  1. Raised after the start state is completed and before the initialization state begins.
  2. IsPostBack property is determined.
  3. Create dynamic controls.
  4. Set or Get profile property values.

Init :

  1. It starts when controls are initialized.
  2. This event is used to set or get properties.
  3. Init event of control occurs before Init event of page.

InitComplete :

  1. This is raised when all initialization is completed.
  2. View State is not loaded, this event can be used to make changes in ViewState.
  3. This event can be used for processing tasks that require all initialization to be completed.

PreLoad :

  1. This is raised when the page loads the ViewState.
  2. Loads the Postback data.

Load :

  1. The page calls the OnLoad method on page object.
  2. Then recursively OnLoad for each control is invoked.

ControlEvents :

  1. Use these events to handle specific control events, such as a Button control’s Click event or a TextBox control’s TextChanged event.

LoadComplete :

  1. Raised at the end of the event-handling stage.
  2. Use this event for tasks that require all other controls on the page to be loaded.

PreRender :

  1. Page Object raises the PreRender event on the Page object, and then recursively does the same for each child control.
  2. This event can also be used to make final changes to the contents of the page or its controls before the rendering stage begins.

PreRenderComplete :

  1. Raised after each data bound control DataSourceID property is set, calls its DataBind method.

SaveStateComplete :

  1. Raised after view state and control state have been saved for the page and for all controls.

Render :

  1. Render is not an event instead this is a process, the Page Object calls this method on each control.

UnLoad :

  1. This event is first raised for each control, then for the page.
  2. Final cleanup is done and all resources and references, such as database connections, are freed in this event.

--

--