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

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
 
J

John Puopolo

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top