473,569 Members | 2,481 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.

Nov 19 '05 #1
4 1001
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
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.


Nov 19 '05 #2
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 InitializeCompo nent method of the code
behind page. This will show code for adding the events for a particular
control on the page.

For example:

this.LinkButton 1.Click += new System.EventHan dler(this.Page_ Load);

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

This response is supplied "as is" without any representations or warranties.
<jo********@yah oo.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
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.

Nov 19 '05 #3
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

Nov 19 '05 #4
I didn't say you couldn't do it (I don't think I said that). You'd need to
use reflection to do this.

-Brock
DevelopMentor
http://staff.develop.com/ballen
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


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3300
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It is possible to Add and Delete rows - Some cells have special attributes (readonly and events) Here's a snippet of the code:
3
2022
by: Sasha | last post by:
Hi everyone, Here is my problem: I have the following classes: - DataNode - this class is designed to hold some data and will be contained in a tree like data structure DataTree. When DataNode is changed, it raises "Changed" event. The class has a reference to the DataNode it is being contained in: - DataTree - tree like data structure...
1
2274
by: Bruce M. Carroll | last post by:
I am doing some work a distributed application, which uses events and remoting to accomplish the signaling between applications. This all works. The problem I have (I think) is that since remoting/events essentially guarantees that you are working in a multi-threaded environment, the developer of the application that consumes these events,...
16
2883
by: anonymous.user0 | last post by:
The way I understand it, if I have an object Listener that has registered as a listener for some event Event that's produced by an object Emitter, as long as Emitter is still allocated Listener will stay alive. Is this correct? If this is correct, I've got a problem. Let's say I've got an object Customer that has an PurchaseList...
6
2254
by: Joseph Geretz | last post by:
Writing an Outlook AddIn with C#. For the user interface within Outlook I'm adding matching pairs of Toolbar buttons and Menu items. All of the buttons and menu items are wired up to send events to the same method (aka delegate?). I use the Tag property within this method to determine what user action is taking place. Very simple: When...
7
3435
by: sam.m.gardiner | last post by:
I'm working with VB.NET events and I want a way to disconnect all the handlers of an event. I want to do this in the object that is the source of the event. This is slightly tricky in VB.Net as the eventing code is slightly hidden. when you use events in Vb.Net you type this: <code> Public event MyEvent() </code>
5
2752
by: Daniel | last post by:
Hey guys When you hook an event (c# 2.0 syntax): myEvent += MyMethodToFire; You need to also unsubscribe it to avoid a resource leak so that the object it is in gets garbage collected like so : myEvent -= MyMethodToFire; That's all fine, but when you use visual studio to create events for objects it never creates an unsubscribing...
7
2321
by: mavigozler | last post by:
IE7 does not appear to set an event on contained text inside SPAN elements whose 'onclick', 'onmouseover', and 'onmouseout' events, defying the HTML recommendation. Firefox appears to conform. Is that so?
11
3235
by: MikeT | last post by:
This may sound very elementary, but can you trap when your object is set to null within the object? I have created a class that registers an event from an object passed in the constructor. When my object is destroyed, I want my object to un-register this event. If I don't then the object would never be destroyed until the object I passed...
15
6522
by: damiensawyer | last post by:
Hi, I am creating a class (from a base class) that needs to trigger events (code at bottom). I am instatiating the classes and wiring up the events as follows. clsDetermineConnection oDC = new clsDetermineConnection(Request); oDC.LogMessage += new RunTraceBase.TraceArguments(LogMessagesFromEvents);
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.