What are Events in ASP.NET Page Life Cycle?
At each stage of the page life cycle, the page fires some events, we can write code on these event.
Asp.net Page life cycle events given below:
- PreInit – PreInit is the very first event in page life cycle. It checks the IsPostBack property and determines whether the page is a postback or not. In this event we can sets the themes and master pages, creates dynamic controls, and gets and sets profile property values. This event can be handled by overloading the OnPreInit method.
- Init – Init event initializes the control property and the control tree is built. This event can be handled by overloading the OnInit method.
- InitComplete – you can use this event to make changes to the view state that you want to ensure are persisted after the next postback.
- LoadViewState – LoadViewState event allows loading view state information into the controls.
- LoadPostData – During this phase, the contents of all the input fields are defined with the <form> tag are processed.
- PreLoad – PreLoad occurs before the post back data is loaded in the controls.
- Load – The Load event is raised for the page first and then recursively for all child controls.
- LoadComplete – The loading process is completed, control event handlers are run, and page validation takes place.
- PreRender – The PreRender event occurs just before the output is rendered.
- PreRenderComplete – As the PreRender event is recursively fired for all child controls.
- SaveStateComplete – State of control on the page is saved. Personalization, control state and view state information is saved. The HTML markup is generated in this event.
- UnLoad – The UnLoad phase is the last phase of the page life cycle.This is the page cleaning process such as Instances cleaning or objects,closing the database connections ,closing the opened file