Tuesday, February 7, 2012

Page_Init vs Page_Load



  • During page initialization, controls on the page are available and each control's UniqueID property is set. Any themes are also applied to the page. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.
  • During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state.
  • Use Page_Init when you have to create controls dynamically. The controls are created every time that the page is run. The best place to do this is in the Page_Init function.
Reference:
ASP.NET Page Life Cycle Overview
HOW TO: Dynamically Create Controls in ASP.NET with Visual Basic .NET

No comments:

Post a Comment