The Page Life Cycle of an ASP.NET and its controls.
The life cycle starts when a user requests a web page through his/her browser. The Web server than process the page through a sequence of steps before response is sent back to the user's browser. The steps are as:
- Page Request
- Start
- Page Initialization
- Load
- Validation
- PostBack Event Handling
- Render
- Unload
Page Request
The page request occurs before the page life cycle begins. When a user requests the page, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.
Start
In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. Additionally, during the start step, the page's UICulture property is set.
Page Initialization
During page initialization, controls on the page are available and each control's UniqueID are generated but not their properties. Any themes are also applied to the page.
Developers have access to the Init, InitComplete and PreLoad methods in this stage. The methods are as follows:
The page request occurs before the page life cycle begins. When a user requests the page, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.
Start
In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. Additionally, during the start step, the page's UICulture property is set.
Page Initialization
During page initialization, controls on the page are available and each control's UniqueID are generated but not their properties. Any themes are also applied to the page.
Developers have access to the Init, InitComplete and PreLoad methods in this stage. The methods are as follows:
- Init: This event is raised after all controls have been initialized and any skin settings have been applied. This event is used to read or initialize control properties.
- InitComplete: The Page object raises this event. This event is used for processing tasks that require completion of all initialization.
- PreLoad: Use this event if you need to perform processing on your page or control before the Load event. After the Page raises this event, it loads view state for itself and all controls, and then processes any postback data included with the Request instance.
Load
During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state. The OnLoad event method is fired during this stage.
This is where you will want to set properties for all of the server controls on your page, request query strings, and establish database connections.
Validation
During validation, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.
PostBack Event Handling
If the request is a postback, any event handlers are called. The event handling for server controls occurs during this stage.
Render
During rendering, view state is saved to the page and then the page calls on each control to contribute its rendered output to the OutputStream of the page's Response property. Render is not really an event. The HTML of the page and all controls are sent to the browser for rendering.
Unload
Unload is called when the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed. The cleanup includes routines such as closing database connections and file streams, or, event logging and other tasks.
During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state. The OnLoad event method is fired during this stage.
This is where you will want to set properties for all of the server controls on your page, request query strings, and establish database connections.
Validation
During validation, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.
PostBack Event Handling
If the request is a postback, any event handlers are called. The event handling for server controls occurs during this stage.
Render
During rendering, view state is saved to the page and then the page calls on each control to contribute its rendered output to the OutputStream of the page's Response property. Render is not really an event. The HTML of the page and all controls are sent to the browser for rendering.
Unload
Unload is called when the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed. The cleanup includes routines such as closing database connections and file streams, or, event logging and other tasks.
Conclusion
When a Web page is requested, the server creates objects associated with the page and all of its child controls objects and uses these to render the page to the browser. Once the final stage is complete, the web server destroys these objects, to free up resource to handle additional request.
I hope that this article would have helped you in understanding the Page Life Cycle in ASP.NET and its controls. Your feedback and constructive contributions are welcome.
Thanx:
Dinesh Wadhwa.
nice code........
ReplyDeleteFriends check this out too....
Earn upto Rs. 9,000 pm checking Emails. Join now!
i was already join...
ReplyDeletenow how we earn money?
This is a nice article..
ReplyDeleteIts easy to understand ..
And this article is using to learn something about it..
c#, dot.net, php tutorial, Ms sql server
Thanks a lot..!
ri70
thank you...Muhammad Azeem..
ReplyDeleteHey! I simply would like to give a huge thumbs up for the good data you have right here on this
ReplyDeletepost. I might be coming back to your weblog for extra soon.
Here is my page benefit shower cap
Thank You.
DeleteGood day! I just want to give a huge thumbs up for the good info you could have right here on this post.
ReplyDeleteI will be coming again to your weblog for more soon.
Also visit my web blog ... bollywood
Hey! I just want to give a huge thumbs up for the nice data you’ve here on
ReplyDeletethis post. I shall be coming again to your blog for
extra soon.
Review my blog :: add new tag
Hey! I simply wish to give a huge thumbs up for the good data you may
ReplyDeletehave right here on this post. I shall be coming back to your blog for more soon.
my website: foreign travel adapter plugs
Whats up! I simply want to give an enormous thumbs up for the nice info you’ve gotten here on this post.
ReplyDeleteI might be coming back to your blog for extra soon.
My weblog ... immobilien kaufen spanien costa blanca
Good day! I simply would like to give an enormous thumbs up for the great information you’ve
ReplyDeletegot right here on this post. I shall be coming again to your blog for extra soon.
Feel free to visit my webpage ... best laptops on the market 2012
Whats up! I just wish to give an enormous thumbs up for the nice data
ReplyDeleteyou’ve right here on this post. I might be coming back to your weblog for more soon.
Check out my weblog ... the truth about 6 pack abs scam
Howdy! I simply want to give a huge thumbs up for the good information you’ve here
ReplyDeleteon this post. I will likely be coming back to your weblog for more soon.
Have a look at my blog - 헉
Hello! I just want to give an enormous thumbs up for the
ReplyDeletegood information you have got right here on this post.
I might be coming again to your blog for extra soon.
Here is my weblog :: rubbing alcohol 70 or 91
Any Continent By using a Hundred Tube
ReplyDeleteHere is my website ... ViewSonic Pro9000
Where to locate House Jobsite set ups Companies: Haverhill
ReplyDeleteMy web-site :: eurocasino ()
What the heck is Involved By using a Plumbing Evaluation?
ReplyDeleteHere is my web blog ... video to mp3 download
Plasma Tv set Buying Guidebook
ReplyDeleteAlso visit my web page; best home projectors
A healthy mouth and a beautiful smile can only be gained from a thorough dental care.
ReplyDeleteYou simply need to take 3 to 4 spoons of hydrogen peroxide in a cup.
You require just a smile to warm the heart of
the people around you and form a great rapport and relation with them.
Here is my web-site ... best tooth whitening ()
However, many times it is likely to show this strange red ring of death error.
ReplyDeleteMost importantly though, this game is a lot of fun. Details have not been announced yet but Texture Packs and Skin Packs will be supported.
Also visit my weblog :: free xbox live gold membership
Fairly recently done up my living room so have been on the
ReplyDeletesearch for a contemporary couple of tables, found a few excellent suggestions
though however no store close to where I live sells these!
Look into my site ... indian furniture
For most recent information you have to pay a visit web and on web I found this web page as a
ReplyDeletebest website for hottest updates.
Have a look at my web page ... nuru massage london (Wineagent.Tw.Rpi.edu)
I like all of the points you have made.
ReplyDeletehttp://www.prokr.net/2016/09/saudi-arabia-cleaning-companies-8.html
http://www.prokr.net/2016/09/saudi-arabia-cleaning-companies-11.html
http://www.prokr.net/2016/09/saudi-arabia-cleaning-companies-10.html
http://www.prokr.net/2016/09/saudi-arabia-cleaning-companies-9.html