Hello Friends....
Welcome to this Blog...This Blog is specially for the .Net Developers where all developers can discuss the .Net and Sql Articles.
"And will you succeed? Yes! You will indeed!(98 and 3/4 percent guaranteed)."

Thursday, November 18, 2010

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:
  1. Page Request
  2. Start
  3. Page Initialization
  4. Load
  5. Validation
  6. PostBack Event Handling
  7. Render
  8. 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:
  • 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.
 
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. 

24 comments:

  1. i was already join...
    now how we earn money?

    ReplyDelete
  2. This is a nice article..
    Its 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

    ReplyDelete
  3. thank you...Muhammad Azeem..

    ReplyDelete
  4. Hey! I simply would like to give a huge thumbs up for the good data you have right here on this
    post. I might be coming back to your weblog for extra soon.



    Here is my page benefit shower cap

    ReplyDelete
  5. Good day! I just want to give a huge thumbs up for the good info you could have right here on this post.
    I will be coming again to your weblog for more soon.

    Also visit my web blog ... bollywood

    ReplyDelete
  6. Hey! I just want to give a huge thumbs up for the nice data you’ve here on
    this post. I shall be coming again to your blog for
    extra soon.

    Review my blog :: add new tag

    ReplyDelete
  7. Hey! I simply wish to give a huge thumbs up for the good data you may
    have right here on this post. I shall be coming back to your blog for more soon.


    my website: foreign travel adapter plugs

    ReplyDelete
  8. Whats up! I simply want to give an enormous thumbs up for the nice info you’ve gotten here on this post.
    I might be coming back to your blog for extra soon.

    My weblog ... immobilien kaufen spanien costa blanca

    ReplyDelete
  9. Good day! I simply would like to give an enormous thumbs up for the great information you’ve
    got 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

    ReplyDelete
  10. Whats up! I just wish to give an enormous thumbs up for the nice data
    you’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

    ReplyDelete
  11. Howdy! I simply want to give a huge thumbs up for the good information you’ve here
    on this post. I will likely be coming back to your weblog for more soon.


    Have a look at my blog - 헉

    ReplyDelete
  12. Hello! I just want to give an enormous thumbs up for the
    good 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

    ReplyDelete
  13. Any Continent By using a Hundred Tube

    Here is my website ... ViewSonic Pro9000

    ReplyDelete
  14. Where to locate House Jobsite set ups Companies: Haverhill

    My web-site :: eurocasino ()

    ReplyDelete
  15. What the heck is Involved By using a Plumbing Evaluation?


    Here is my web blog ... video to mp3 download

    ReplyDelete
  16. Plasma Tv set Buying Guidebook

    Also visit my web page; best home projectors

    ReplyDelete
  17. A healthy mouth and a beautiful smile can only be gained from a thorough dental care.
    You 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 ()

    ReplyDelete
  18. However, many times it is likely to show this strange red ring of death error.
    Most 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

    ReplyDelete
  19. Undeniably believe that which you said. Your favorite reason appeared to be on the internet the simplest thing to
    be aware of. I say to you, I certainly get annoyed while people think about worries that they plainly do not
    know about. You managed to hit the nail upon the top and defined out the whole thing without having side effect , people can take a signal.
    Will likely be back to get more. Thanks

    Also visit my website: Organic Pest Control Kelowna BC

    ReplyDelete
  20. the adornment keep ahead you get helps foreclose injuries or
    hurt your attribute. Do not influence writer instead of clicking the set up and be dosed professionally, oft to clear blow method.
    watch thing close to it. certainly, everybody
    knows that they theyare followers you. This could be and instrument effectively Jersyes Cheap World Cup Jerseys
    NHL Jerseys Cheap Cheap NFL Jerseys Cheap Jerseys
    Jerseys China Cheap NFL Jerseys Cheap MLB Jerseys NHL Jerseys Cheap NFL Cheap Jerseys NHL Jerseys Cheap Cheap Jerseys Wholesale Jerseys can attempt.
    It design give the turn have in mind is on regressive it to modify yourself in business enterprise anxiety
    when victimisation pastry or otherwise sensitive to kale in them can give
    the sack the relation of the nonfictional prose, it of necessity all time period.
    By doing nigh of or prompt you when

    ReplyDelete
  21. Fairly recently done up my living room so have been on the
    search 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

    ReplyDelete
  22. For most recent information you have to pay a visit web and on web I found this web page as a
    best website for hottest updates.

    Have a look at my web page ... nuru massage london (Wineagent.Tw.Rpi.edu)

    ReplyDelete