ASP.NET JUMP START SESSION - 3
Abu Md. Khademul Basher
Speaker TechForum,
Microsoft Technical Community
MY PUBLISHED ARTICLE IN CODE PROJECT
 Implementation of MVC Patterns in ASP.NET Web forms
Application.
 MVC Patterns (Active and Passive Model) and its
implementation using ASP.NET Web forms
 Easy way to learn the Asp.Net Built in Membership and Role
using custom controls with example
 Single Page Application performing database CRUD operations
using Backbone and ASP.NET Web API
 Apply Here Map in Windows Phone HTML5 Apps
WINDOWS PHONE APPS
CONTENTS
 ASP.NET Page Life Cycle
ASP.NET PAGE LIFE CYCLE
What is page life cycle?
When a page is requested by the user the request goes
through a series of steps. The periods between the
request and response of a page is called Page Life
Cycle.
 Request- Start of life cycle (send by user).
 Response – End of life cycle (send by server).
ASP.NET PAGE LIFE CYCLE
How to initiate a request?
When you type a url in Browser address bar and press
enter, the Browser sent a page request to the Server.
The sequence diagram of request and response.
ASP.NET PAGE LIFE CYCLE
HTTP Methods:
 GET - Requests data from a specified resource
 POST - Submits data to be processed to a specified
resource
<form method="post" runat="server">
<a href=“http://www.google.com”>Google</a>
<input type=“text” value=“”/>
<input type=“button” value=“Submit”/>
</form>
GENERAL PAGE LIFE-CYCLE STAGES
When a page is requested, it goes through the following stages.
Page request
Start
The page request occurs before
the page life cycle begins.
Page initialization
Load
Validation
Postback event handling
Rendering
Unload
In the start step, page
properties such as
Request and Response
are set.
During page
initialization, controls on the
page are available and each
control's UniqueID property is
set.Control properties are
loaded with information
recovered from view state
and control state.
Validate method of all validator
controls is called.
If the request is a
postback, any event
handlers are called.
During the rendering phase, the
page calls the Render method
for each control.Unload is called after the
page has been fully
rendered
GENERAL PAGE LIFE-CYCLE STAGES
Events rises within each stage of the life cycle and there’s
corresponding event handlers are as follows:
Page Event Handler Stage
PreInit Page_PreInit Page initialization
Init Page_Init Page initialization
InitComplete Page_InitComplete Page initialization
PreLoad Page_PreLoad Load
Load Page_Load Load
Control events ddlCoungry_SelectedIndex
Changed
Load
LoadComplete Page_LoadComplete Load
PreRender Page_PreRender Rendering
SaveStateComplete Page_SaveStateComplete Rendering
Render (Method) Render Rendering
Unload Page_Unload Unload
GENERAL PAGE LIFE-CYCLE STAGES….
Flow Chart view of Page Life Cycle.
Initialize Method:
OnInit
No
Yes
Load View State
Process postback data
Load method:
Onload
First Load?
First Load?
No
Yes
Handle postback events method:
RaisePostBackEvent
Prer ender method:
OnPreRender
Save view state method:
SaveViewState
Render method:
Render
Dispose method:
Dispose
THANK YOU

Asp.net page lifecycle

  • 1.
    ASP.NET JUMP STARTSESSION - 3 Abu Md. Khademul Basher Speaker TechForum, Microsoft Technical Community
  • 2.
    MY PUBLISHED ARTICLEIN CODE PROJECT  Implementation of MVC Patterns in ASP.NET Web forms Application.  MVC Patterns (Active and Passive Model) and its implementation using ASP.NET Web forms  Easy way to learn the Asp.Net Built in Membership and Role using custom controls with example  Single Page Application performing database CRUD operations using Backbone and ASP.NET Web API  Apply Here Map in Windows Phone HTML5 Apps
  • 3.
  • 4.
  • 5.
    ASP.NET PAGE LIFECYCLE What is page life cycle? When a page is requested by the user the request goes through a series of steps. The periods between the request and response of a page is called Page Life Cycle.  Request- Start of life cycle (send by user).  Response – End of life cycle (send by server).
  • 6.
    ASP.NET PAGE LIFECYCLE How to initiate a request? When you type a url in Browser address bar and press enter, the Browser sent a page request to the Server. The sequence diagram of request and response.
  • 7.
    ASP.NET PAGE LIFECYCLE HTTP Methods:  GET - Requests data from a specified resource  POST - Submits data to be processed to a specified resource <form method="post" runat="server"> <a href=“http://www.google.com”>Google</a> <input type=“text” value=“”/> <input type=“button” value=“Submit”/> </form>
  • 8.
    GENERAL PAGE LIFE-CYCLESTAGES When a page is requested, it goes through the following stages. Page request Start The page request occurs before the page life cycle begins. Page initialization Load Validation Postback event handling Rendering Unload In the start step, page properties such as Request and Response are set. During page initialization, controls on the page are available and each control's UniqueID property is set.Control properties are loaded with information recovered from view state and control state. Validate method of all validator controls is called. If the request is a postback, any event handlers are called. During the rendering phase, the page calls the Render method for each control.Unload is called after the page has been fully rendered
  • 9.
    GENERAL PAGE LIFE-CYCLESTAGES Events rises within each stage of the life cycle and there’s corresponding event handlers are as follows: Page Event Handler Stage PreInit Page_PreInit Page initialization Init Page_Init Page initialization InitComplete Page_InitComplete Page initialization PreLoad Page_PreLoad Load Load Page_Load Load Control events ddlCoungry_SelectedIndex Changed Load LoadComplete Page_LoadComplete Load PreRender Page_PreRender Rendering SaveStateComplete Page_SaveStateComplete Rendering Render (Method) Render Rendering Unload Page_Unload Unload
  • 10.
    GENERAL PAGE LIFE-CYCLESTAGES…. Flow Chart view of Page Life Cycle. Initialize Method: OnInit No Yes Load View State Process postback data Load method: Onload First Load? First Load? No Yes Handle postback events method: RaisePostBackEvent Prer ender method: OnPreRender Save view state method: SaveViewState Render method: Render Dispose method: Dispose
  • 11.