.NETGURU
Initializing controls
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngcontrolscs' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Jesse Liberty (VIP)
If I create a simple asp.net test program, and add a control (e.g., a
button), and put in event handlers for init, load, and pre-render, the load
and pre-render events are trapped, but the init event never seems to fire.
Code put into the event handler for init (e.g., a trace.write statement)
does not execute.

What am I misunderstanding? Shouldn't this code execute when the page is
loaded?

-------------------------------
Jesse Liberty, President
Liberty Associates, Inc.
.NET Programming and Training
http://www.LibertyAssociates.com
Reply to this message...
 
    
Andy Smith
how/when are you hooking up the event handlers?

__
Andy Smith
Keyboard Jockey #3a7-2.78.1

-----Original Message-----
From: Jesse Liberty [mailto:Click here to reveal e-mail address]
Sent: Monday, July 01, 2002 7:57 AM
To: aspngcontrolscs
Subject: [aspngcontrolscs] Initializing controls

If I create a simple asp.net test program, and add a control (e.g., a button), and put in event handlers for init, load, and pre-render, the load and pre-render events are trapped, but the init event never seems to fire. Code put into the event handler for init (e.g., a trace.write statement) does not execute.

What am I misunderstanding? Shouldn't this code execute when the page is loaded?

-------------------------------
Jesse Liberty, President
Liberty Associates, Inc.
.NET Programming and Training
http://www.LibertyAssociates.com <http://www.libertyassociates.com/>

| [aspngcontrolscs] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngcontrolscs.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
Reply to this message...
 
    
Jesse Liberty (VIP)
Click on the controls, choose events in properties, double click on the
event you want, fill in the event handlers (all from within VS.NET).

-------------------------------
Jesse Liberty, President
Liberty Associates, Inc.
.NET Programming and Training
http://www.LibertyAssociates.com

-----Original Message-----
From: Andy Smith [mailto:Click here to reveal e-mail address]
Sent: Monday, July 01, 2002 11:41 AM
To: aspngcontrolscs
Subject: [aspngcontrolscs] RE: Initializing controls

how/when are you hooking up the event handlers?

__
Andy Smith
Keyboard Jockey #3a7-2.78.1

-----Original Message-----
From: Jesse Liberty [mailto:Click here to reveal e-mail address]
Sent: Monday, July 01, 2002 7:57 AM
To: aspngcontrolscs
Subject: [aspngcontrolscs] Initializing controls

If I create a simple asp.net test program, and add a control (e.g., a
button), and put in event handlers for init, load, and pre-render, the load
and pre-render events are trapped, but the init event never seems to fire.
Code put into the event handler for init (e.g., a trace.write statement)
does not execute.

What am I misunderstanding? Shouldn't this code execute when the page is
loaded?

-------------------------------
Jesse Liberty, President
Liberty Associates, Inc.
.NET Programming and Training
http://www.LibertyAssociates.com

| [aspngcontrolscs] member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/asplists/aspngcontrolscs.asp = JOIN/QUIT |
http://www.asplists.com/search = SEARCH Archives
| [aspngcontrolscs] member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/asplists/aspngcontrolscs.asp = JOIN/QUIT |
http://www.asplists.com/search = SEARCH Archives
Reply to this message...
 
    
Andy Smith
well, I just tried it, and got the same behavior.
then i looked at how vstudio attaches the event handlers. It does it in =
the InitializeComponent, which gets called in the OnInit area of the =
Page object, before base.OnInit.

The problem is that this happens too late, AFTER the button's init gets =
raised. add a Trace.Write to the OnInit override of the Page before the =
InitializeComponent call, and then set the oninit attribute of the =
button tag to your handler and put a trace.write in that handler. you'll =
see that the Page's OnInit gets called after the Init event of its child =
controls, and therefore you can't hook up a handler.

This is a design flaw of the IDE, not the framework. A parent control's =
init event must happen after its children... otherwise the init event =
wouldn't be very usefull.

I can't think of any way to assign an init handler for a parsed control =
on the page from codebehind. The only way I can think of is to set the =
oninit attribute, which the ControlBuilder ( i believe that's the class =
responsible ) will use to attach the event.

__
Andy Smith
Keyboard Jockey #3a7-2.78.1

-----Original Message-----
From: Jesse Liberty [mailto:Click here to reveal e-mail address]
Sent: Monday, July 01, 2002 11:36 AM
To: aspngcontrolscs
Subject: [aspngcontrolscs] RE: Initializing controls

Click on the controls, choose events in properties, double click on the =
event you want, fill in the event handlers (all from within VS.NET).=20

-------------------------------
Jesse Liberty, President
Liberty Associates, Inc.
.NET Programming and Training
http://www.LibertyAssociates.com=20
-----Original Message-----
From: Andy Smith [mailto:Click here to reveal e-mail address]
Sent: Monday, July 01, 2002 11:41 AM
To: aspngcontrolscs
Subject: [aspngcontrolscs] RE: Initializing controls

how/when are you hooking up the event handlers?

__
Andy Smith
Keyboard Jockey #3a7-2.78.1

-----Original Message-----
From: Jesse Liberty [mailto:Click here to reveal e-mail address]
Sent: Monday, July 01, 2002 7:57 AM
To: aspngcontrolscs
Subject: [aspngcontrolscs] Initializing controls

If I create a simple asp.net test program, and add a control (e.g., a =
button), and put in event handlers for init, load, and pre-render, the =
load and pre-render events are trapped, but the init event never seems =
to fire. Code put into the event handler for init (e.g., a trace.write =
statement) does not execute.

What am I misunderstanding? Shouldn't this code execute when the page is =
loaded?

-------------------------------
Jesse Liberty, President
Liberty Associates, Inc.
.NET Programming and Training
http://www.LibertyAssociates.com=20

| [aspngcontrolscs] member Click here to reveal e-mail address =3D YOUR ID | =
http://www.asplists.com/asplists/aspngcontrolscs.asp =3D JOIN/QUIT | =
http://www.asplists.com/search =3D SEARCH Archives=20
| [aspngcontrolscs] member Click here to reveal e-mail address =3D YOUR ID | =
http://www.asplists.com/asplists/aspngcontrolscs.asp =3D JOIN/QUIT | =
http://www.asplists.com/search =3D SEARCH Archives=20
| [aspngcontrolscs] member Click here to reveal e-mail address =3D YOUR ID | =
http://www.asplists.com/asplists/aspngcontrolscs.asp =3D JOIN/QUIT | =
http://www.asplists.com/search =3D SEARCH Archives=20

Reply to this message...
 
 
System.Diagnostics.Trace
System.Web.UI.ControlBuilder




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification