Delegate Creation
am 16.01.2008 18:53:56 von smar
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?
Re: Delegate Creation
am 16.01.2008 18:57:30 von grava
"Scott M." wrote in message
news:e5mMhhGWIHA.6044@TK2MSFTNGP05.phx.gbl...
> 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
--
Gianluca Gravina
http://blogs.ugidotnet.org/thinkingingrava
Re: Delegate Creation
am 16.01.2008 19:04:47 von smar
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.
"Scott M." wrote in message
news:e5mMhhGWIHA.6044@TK2MSFTNGP05.phx.gbl...
> 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?
>
Re: Delegate Creation
am 16.01.2008 19:33:39 von smar
Ok, that's what I thought. Thanks!
"grava" wrote in message
news:AE5406F7-53F9-40EA-A8AD-5D87F3992C00@microsoft.com...
>
>
> "Scott M." wrote in message
> news:e5mMhhGWIHA.6044@TK2MSFTNGP05.phx.gbl...
>> 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
>
>
> --
> Gianluca Gravina
> http://blogs.ugidotnet.org/thinkingingrava