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

Discussion in 'ASP .Net' started by johngilmer@yahoo.com, May 5, 2005.

  1. Guest

    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.
     
    , May 5, 2005
    #1
    1. Advertising

  2. Brock Allen Guest

    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.
     
    Brock Allen, May 5, 2005
    #2
    1. Advertising

  3. David Lloyd Guest

    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.


    <> wrote in message
    news:...
    > 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.
    >
     
    David Lloyd, May 5, 2005
    #3
  4. Guest

    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
     
    , May 12, 2005
    #4
  5. Brock Allen Guest

    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
     
    Brock Allen, May 12, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RA
    Replies:
    2
    Views:
    2,572
  2. Doug
    Replies:
    3
    Views:
    4,379
    Bruce Barker
    Nov 4, 2005
  3. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    374
    Chris
    Aug 30, 2005
  4. Grant Schenck
    Replies:
    9
    Views:
    194
    [MSFT]
    Apr 26, 2005
  5. fuubaa

    Mouse events, classes, handlers

    fuubaa, Feb 17, 2006, in forum: Javascript
    Replies:
    1
    Views:
    91
    Thomas 'PointedEars' Lahn
    Feb 17, 2006
Loading...

Share This Page