Breaking News

ASP.NET Page Life Cycle

ASP.NET Page Life Cycle Whenever a page is requested after that it is loaded into the server memory, processed and sent to the browser. Then it is unloaded from the memory.you can also write your own code to override the default code.

The Page class creates a hierarchical tree of all the controls on the page. All the components on the page, except the directives are the part of this control tree. You can also see the control tree by adding trace= “true” to the Page directive.

The page life cycle phases:

• Initialization
• Instantiation of the controls on the page
• Restoration and maintenance of the state
• Execution of the event handler codes
• Page rendering

The page life cycle of ASP.NET helps in writing custom controls and initializing them at right time, populate their properties with view-state data and run control behavior code.

Following are the different stages of an ASP.NET page:
Page request:
At this phase ,the ASP.NET gets a page request and then it decides whether to resolve and compile the page,accordingly the response is sent.
Starting of page life cycle:
At this phase, the Request and Response objects are set. If the request is an old request or post back then the IsPostBack property of the page is set to true.
Page initialization:
At this phase, the controls on the page are assigned with unique ID by setting the UniqueID property and at the same time themes are also applied.But for a new request postback data is loaded and the control properties are restored to the view-state values.
Page load:
At this phase, the user set the control properties using the view state and control state values.
Validation:
At this phase,the Validate method of the validation control is called and if it runs successfully then the IsValid property of the page is set to true.
Postback event handling:
At this phase,The event handler is called if the request is a postback(old request).
Page rendering:
At this phase, the view state for the page and all controls are saved. The page calls the Render method for each control and the output of rendering is written to the OutputStream class of the Page’s Response property.
Unload:
At this phase,the rendered page and page properties is sent to the client.

Check Also

BulletList Server Control

BulletList Server Control The BulletedList server control is used to display a bulleted list of items in …