Tuesday, 8 October 2013

ASP.Net Page Life Cycle

When a page is requested, it's loaded into the server memory, processed and sent to the browser. Then it's blank from the memory. At every of this steps, strategies and events area unit obtainable, that can be overridden in keeping with the necessity of the applying. In alternative words, you'll be able to write your own code to override the default code.

The Page category creates a graded tree of all the controls on the page. All the parts on the page, except the directives area unit a part of this management tree. you'll be able to see the management tree by adding trace= "true" to the Page directive. we'll cowl page directives and tracing below 'directives' and 'error handling'.

The page life cycle phases are:

Initialization

Instantiation of the controls on the page

Restoration and maintenance of the state

Execution of the event handler codes

Page rendering

Understanding the page cycle helps in writing codes for creating some specific factor happen at any stage of the page life cycle. It additionally helps in writing custom controls and initializing them at right time, populate their properties with view-state information and run management behavior code.

Following area unit the various stages of AN ASP.Net page:

Page request . when ASP.Net gets a page request, it decides whether or not to break down and compile the page or there would be a cached version of the page; consequently the response is shipped

Starting of page life cycle . at this stage, the Request and Response objects area unit set. If the request is AN previous request or post back, the IsPostBack property of the page is about to true. The UICulture property of the page is additionally set.

Page low-level formatting . at this stage, the controls on the page area unit allotted distinctive ID by setting the UniqueID property and themes area unit applied. For a brand new request postback information is loaded and also the management properties area unit fixed up to the view-state values.

Page load . at this stage, management properties area unit set mistreatment the read state and management state values.

Validation . Validate technique of the validation management is named and if it runs with success, the IsValid property of the page is about to true.

Postback event handling . if the request could be a postback (old request), the connected event handler is named.

Page rendering . at this stage, read state for the page and every one controls area unit saved. The page calls the Render technique for every management and also the output of rendering is written to the OutputStream category of the Page's Response property.

Unload . the rendered page is shipped to the shopper and page properties, like Response and Request area unit blank and every one cleanup done.

0 comments:

Post a Comment