Adsence750x90

Wednesday, September 2, 2009

General page life Cycle Stages in ASP.NET

General page life Cycle Stages in ASP.NET
1: Page Request
2: Start
3: Page Initializations
4: Load
5: Validation
6: Postback event handling
7: Rendering
8: Unload

1: Page Request:

The Page Request occurs before the page life cycle start. When a page is requested by a user ASP.NET determine some common things
1: whether the page need to be parsed and compiled
2: whether a cached version of the page can be sent in response without running the current page

2: Start

In start, page properties like request and response are set. In this stage the page also determine whether the request is a Postback or new request and set IsPostBack Property.

3: Page Initializations

During page initialization, controls on page are available and each control set its uniqueid property is set and themes. ie control raise their Init ViewState is set in this stage.

4: Load

On load if the current request is Postback control property are loaded with information recoved from viewstate and control state


Control state: Control state, introduced in ASP.NET version 2.0, is similar to view state but functionally independent of view state. A page developer can disable view state for the page or for an individual control for performance. However, control state cannot be disabled. Control state is designed for storing a control's essential data (such as a pager control's page number) that must be available on postback to enable the control to function even when view state has been disabled. By default, the ASP.NET page framework stores control state in the page in the same hidden element in which it stores view state. Even if view state is disabled, or when state is managed using Session, control state travels to the client and back to the server in the page. On postback, ASP.NET deserializes the contents of the hidden element and loads control state into each control that is registered for control state.
Note:
Use control state only for small amounts of critical data that are essential for the control across postbacks. Do not use control state as an alternative to view state.


Control state FROM MSDN


5: Validation

Validate method of all validator control is called, which set the IsValid property of individual validator controls in the requested page.

6: Postback event handling

If the request is a Postback any events handlers are called. And save viewstate

7: Rendering

Before rendering viewstate is saved for the page and all control.during the rendering phase the page calls the Render method for each control.

8: Unload

Unload call after the page has been fully rendered,sent to the client and is ready to be discarded.

1 comment:

Bijayani said...

Hi,

I happened to see your post find it quite informative. I would like to share a link where a software engineer has shared a tip on "Warning the user before leaving the page in ASP.Net" with the coding.

http://www.mindfiresolutions.com/warning-the-user-before-leaving-the-page-792.php

Hope you find it useful and of assistance.

Thanks,
Bijayani