Page Life Cycle — ASP.NET
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:
PerInit :
- Raised after the start state is completed and before the initialization state begins.
- IsPostBack property is determined.
- Create dynamic controls.
- Set or Get profile property values.
Init :
- It starts when controls are initialized.
- This event is used to set or get properties.
- Init event of control occurs before Init event of page.
InitComplete :
- This is raised when all initialization is completed.
- View State is not loaded, this event can be used to make changes in ViewState.
- This event can be used for processing tasks that require all initialization to be completed.
PreLoad :
- This is raised when the page loads the ViewState.
- Loads the Postback data.
Load :
- The page calls the OnLoad method on page object.
- Then recursively OnLoad for each control is invoked.
ControlEvents :
- Use these events to handle specific control events, such as a Button control’s Click event or a TextBox control’s TextChanged event.
LoadComplete :
- Raised at the end of the event-handling stage.
- Use this event for tasks that require all other controls on the page to be loaded.
PreRender :
- Page Object raises the PreRender event on the Page object, and then recursively does the same for each child control.
- 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 :
- Raised after each data bound control DataSourceID property is set, calls its DataBind method.
SaveStateComplete :
- Raised after view state and control state have been saved for the page and for all controls.
Render :
- Render is not an event instead this is a process, the Page Object calls this method on each control.
UnLoad :
- This event is first raised for each control, then for the page.
- Final cleanup is done and all resources and references, such as database connections, are freed in this event.