ASP control initialization via onInit attribute vs. in the Page_Load method

  • Thread starter Thread starter Neil Zanella
  • Start date Start date
N

Neil Zanella

Hello,

I would like to ask a question pertaining to programmatic
initialization of ASP web controls (as opposed to initialization
via standalone attributes and other elements contained in the
enclosing ASP control element)...

Given an ASP web control that supports specifying an
initialization event handler via the onInit attribute,
what is the difference between placing initialization
code in such an event handler and placing it within
the Page_Load method for the ASP.NET page?

Thank you for your replies,

Neil
 
Hi...

During the OnInit method, the other controls may or may not be created ---
you cannot rely on their being available. In addition, the ViewState will
not have been set up yet. The OnLoad event, however, executes after the
server controls have been created, the ViewState has been restored and
client-side changes to the data have been reflected. This is much later in
the processes than the OnInit method for an individual control.

Hope this helps,
John
 
Back
Top