Delegate Creation

S

Scott M.

In a new VS 2005 ASP .NET Web Application Project (WAP), I'm looking at the
..designer.cs file to see how the event handlers for my page controls are
wired up to the events.

I was expecting to see the delegates being associated with the event
handling methods in the page (like in a Windows app), but instead found
nothing in either the .aspx.cs or the .aspx.designer.cs file that seems to
resemble anything having to do with wiring up events to the event handlers.

So, my question is: where is this code?
 
G

grava

Scott M. said:
In a new VS 2005 ASP .NET Web Application Project (WAP), I'm looking at
the .designer.cs file to see how the event handlers for my page controls
are wired up to the events.

I was expecting to see the delegates being associated with the event
handling methods in the page (like in a Windows app), but instead found
nothing in either the .aspx.cs or the .aspx.designer.cs file that seems to
resemble anything having to do with wiring up events to the event
handlers.

So, my question is: where is this code?

No code for events if in yout aspx page you've got (default is true)
autoeventWireUp Attribute set to true.

So if you set this attribute to false you've got to override init event to
hook events to methods eg:

protected void Page_Load(object sender, EventArgs e)
{
...
}

override init(object sender, EventArgs e)
{
this.Load += new System.EventHandler(this.Page_Load);
}

HTH
 
S

Scott M.

I do see that the .aspx page directive of "AutoEventWireUp" is set to true.
I know that in VB .NET that means that the event is automatically wired up
to its event handler based on the name of the event handler being a
combination of the controlID an underscore and a valid event name.

Is this the same in C#? I guess so.
 
S

Scott M.

Ok, that's what I thought. Thanks!


grava said:
No code for events if in yout aspx page you've got (default is true)
autoeventWireUp Attribute set to true.

So if you set this attribute to false you've got to override init event to
hook events to methods eg:

protected void Page_Load(object sender, EventArgs e)
{
...
}

override init(object sender, EventArgs e)
{
this.Load += new System.EventHandler(this.Page_Load);
}

HTH
 

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

Top