15 August, 2011

Important Notes in Asp.net

server controls have their own life-cycle same as page life-cycle, but there is minor change in the order they raised events. so, it is very important to understand to order of clontrol's and page life-cycle events and methods.

Init and Unload Events

In simple words,
  • it follows BOTTOM-UP approch.
  • so, first child control's Init/Unload event will be called.
  • then parent control's Init/Unload event will take place.

Load Events

In simple words,
  • it follows TOP-DOWN approch.
  • so, first parent control's Load event will take place.
  • then child control's Load event will be called.
Master page's considration

In simple words,
  • it behave like child's controls approch.
  • so, first Master page's Init Event will be called.
  • then child page's Init and Load event will be called.
  • at last,  Master page's Load Event will be called.




    Figure shows some of the most important methods of the Page class that you can override in order to add code that executes at specific points in the page life cycle.The sequence of methods and events in the illustration is from top to bottom, and within each row from left to right.

    Note :
    •  when we override some base class's method, we must explicitly  call base Method. 
    •  For eg: if you override the OnLoad method on the page, you must call base.Load  (MyBase.Load in Visual Basic) in order for the base implementation to be run.
    • you can override the page's InitializeCulture method to dynamically set culture information. but must call base.InitializeCulture 

    No comments:

    Post a Comment