Wednesday, August 17, 2016

Page Event

1. PreInit
  • Check the IsPostBack property and determines whether this is the first time the page is being processed. (IsPostback, IsCallback and IsCrossPagePostback properties have to set at this time.
  • For dynamic control.
  • Dynamically set the values of Themes.
  • Dynamically set the values Master Pages. (get error if you set masterpage after preinit)
  • You can get the Master Page Control Properties (but cannot get page control itself), but you can't get Master Page input value.
2. Init
  • This event fires after each control has been initialized. (TextBox != null)
  • Read and Initialize Control properties. (You can Get Button Colour or Change Button Colour)
  • Viewstate Restoration at here.
  • You can get the initialize value. (pre set Textbox.text = "123")
  •  You cannot get input value or postback value. (Same as MasterPage input value)
3. InitComplete 
  •  You can make changes to the view state. (Textbox = 123, this 123 will show in screen)
4. PreLoad 
  • Load Viewstate and Control.
  • Viewstate functionality starts retrieving their values. you can get value from viewstate
  • If you input 456 to textbox, and assign value to tetbox="123" , the screen will dispay the "123"
  • It receive value from Control. 
  • Postback data are now handed to the page controls.
5. Load
  • First place in page lifecycle that all values are restored.
  • Check the value of IsPostBack to avoid unnecessarily resetting state.
  • Check the value of IsValid. (Page.IsValid for checking validators such as  requiredFieldValidator, regularexpressionValidator , Range etc)
6. LoadComplete 
  • This event can be used when all the event processing has been done in the page.
  • Page_Load event will always happen before any control events get fired (Button_Click). If you need to do something after the control event, use LoadComplete or Page_PreRender.
7. PreRender
  • Last chance to change the page or control or viewstate before it turns into HTML stream.
8. PreRenderComplete
  • As the PreRender event is recursively fired for all child controls, this event ensures the completion of the pre-rendering phase.
  • Dispay in HTML
9. SaveStateComplete
  • State of control on the page is saved. Personalization, control state and view state information is saved, any changes will be ignore. (HTML will still display, but the value is not, next time u get the value , you will get value of PreRenderComplete or before )
  • The HTML markup is generated. 
10. UnLoad
  • The UnLoad phase is the last phase of the page life cycle. 
  • It raises the UnLoad event for all controls recursively and lastly for the page itself.
  • Final cleanup is done and all resources and references, such as closing opened File, database connections.

No comments:

Post a Comment