Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Asp.Net Page Life Cycle

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.01k
    Comment on it

    Asp.Net Page Life Cycle

    In this blog I am going to explain life cycle of Asp.net page. The first thing comes in mind is "what is page life cycle?".

    Page Life Cycle

    It is the process of how a page is served by a web server to the browser. Page's life cycle starts with initial request of page by browser till page has been rendered. Certain events are going on during page life cycle.

    SILVER-U - A simple way to remember ASP.NET page life cycle.

    S-Start.

    I-Initialization.

    L-Load.

    V-Validation.

    E-Event handling.

    R-Rendering.

    U-Unload.

    Description Of Events That Occur During Life Cycle Of Asp.Net Page

    1. Page Request

    When a request to render a page is made by browser to a web server. A request to render ASPX page starts the life cycle of Asp.Net page.

    2. Start

    In this phase, the page gets access to properties like Request and Response that are used to interact with the pages environment.

    3. Page Initialization

    During this phase, the controls that you have set up in your page or added dynamically will become available. Additionally, the Page class fires three events: Init, InitComplete, and PreLoad. "Page.Init" event fires ASP.NET checks to determine whether the page is requested for first time or it is a postback. If the request is a new one, then ASP.NET creates the page. It generates the page with all the controls defined in the .aspx page.

    4. Load

    In this phase page raises the Load event. In this event, initialization such as populating the dynamic controls or dropdown list etc is done. Page always raises this event, it doesn't matter whether the page is loaded for first time or it is a postback. Initialization is to be done only once. On a postback, ASP.NET restores the control properties automatically from ViewState information.

    5. Validation

    Validation controls are used to validate user input before processing. After the page is loaded, validation controls gets fired and displays error messages. You just have to check whether the Page.IsValid is true or false.

    6. Postback Event Handling

    In this phase controls like button,dropdown etc can fire their event. when a button is clicked or dropdown's selected index is changed onclick() and onchange() is fired respectively. When onclick() or onchange() event is fired it makes a postback.

    7. Rendering

    Rendering is the phase where the controls and the page itself output their HTML to the browser.

    8. Unload

    The unload phase is really a clean-up phase. In this phase the page and controls releases resources and "Response" and "Request" properties of page are unloaded. During this phase, the Unload event is raised and any operations required to clean-up can be performed.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: