Hi Natty,
You still don't get it. I _know_ a delegate is needed. It can't work without
it. Please read my post again. I'll try to make it really simple for you, as
perhaps English is not your first language.
Look at this declaration for an asp:linkbutton
<asp:linkbutton runat="server" onclick="myhandler" id="btn1" />
^^^^^^^^^^^^^^^^^^^
The sgml attribute "onclick" is specifying a method to handle the click
event. If you check out the codebehind for this page, you'll see that there
is NO code to tie the delegate to the eventhandler. It just works. It is
added at run-time, not compile-time. The only thing the IDE will add is a
variable reference, e.g. "protected System.Web.UI.WebControls.LinkButton
btn1;".
Think about it for a second. If I added:
btn1.click += new EventHandler(this.myhandler)
to my codebehind page, why would I need 'onclick="myhandler"' on the
declaration? Yes, that's right -- I wouldn't need it. Understand now? I was
asking if anyone knew the [Attribute] or suitable reflection code to use to
automatically wireup sgml attribute eventhandlers.
Agh!! :-)
- Oisin
"Natty Gur" <na***@dao2com.com> wrote in message
news:eG*************@TK2MSFTNGP11.phx.gbl...
Hi,
Sorry about my misunderstanding.
Any way you can't do it without using EventHandler. Every event that
needs to be handling must use it in order to attach function to the
event. Even the linkbutton click event uses it. You can see it in
InitializeComponent function. The only different is that VS embed the
code for you.
private void InitializeComponent()
{
this.LinkButton1.Click += new
System.EventHandler(this.LinkButton1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114
Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377
Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!