How can I read the events handlers of a UI object?

  • Thread starter Thread starter johngilmer
  • Start date Start date
J

johngilmer

I posted this question a couple days ago on , but didn't get any
answers, so I will try here.

My issue: there is a link button with an event handler for a Click
event. I want to create another link button that will act exactly like
the first. So I want to set its Click event handler to be the same as
the first one. But I can't figure out how I can see what the first
one's event handler is.
thanks in advance.
 
Oh, you want to interogate a control to get everyone who's registered for
an event on said control? You can't, as the delegate is private inside of
the control. If it were public then it'd not be a problem. So you can either
derive your own that makes it public or use reflection to bypass the access
modifier.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
John:

If you are using Visual Studio, select the link button and view the
properties window. Then select the button at the top of this window that
looks like a lightning bolt. That will show you the events for the link
button and what event handler is set for the Click event.

A second method is to examine the InitializeComponent method of the code
behind page. This will show code for adding the events for a particular
control on the page.

For example:

this.LinkButton1.Click += new System.EventHandler(this.Page_Load);

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
 
David,
Thanks for the reply. What I want is not to see the handlers at design
time, but to detect it at runtime. So I want to query the object while
the application is running to ask it what its event handlers are. But
it seems from the other response I got from
Brock Allen that it might not be possible because it's private.
John
 
Back
Top