ASP.NET Page Life Cycle Events

ASP.NET Page Life Cycle Events

events can occur at 3 levels in an web application.

1. At the application level. (Example – Session_Start event in global.asax)
2. At the Page or web form level (Example – Page_Load)
3. At the control level(Example – Selected Index changed event of a dropdownlist)

The following are some of the commonly used events in the life cycle of an webform. These events are shown in order of occurrence, except for, Error event, which occurs only if there is an unhandled exception.
PreInit – As the name suggests, this event happens just before page initialization event starts.  IsPostBack, IsCallback and IsCrossPagePostBack properties are set at this stage. This event allows us to set the master page and theme of a web application dynamically. PreInit is extensively used when working with dynamic controls.

Init – Page Init, event occurs after the Init event, of all the individual controls on the webform. Use this event to read or initialize control properties. The server controls are loaded and initialized from the Web form’s view state.

InitComplete – As the name says, this event gets raised immediately after page initialization.

PreLoad – Happens just before the Page Load event.

Load – Page Load event, occurs before the load event of all the individual controls on that webform. 

Control Events – After the Page load event, the control events like button’s click, dropdownlist’s selected index changed events are raised.

Load Complete – This event is raised after the control events are handled.

PreRender – This event is raised just before the rendering stage of the page. 

PreRenderComplete – Raised immediately after the PreRender event.

Unload – Raised for each control and then for the page. At this stage the page is, unloaded from memory.

Error – This event occurs only if there is an unhandled exception.

About the author


Leave a Comment