Fire Event From User Control

Discussion in 'ASP .Net Web Controls' started by Da Rabit, Nov 11, 2004.

  1. Da Rabit

    Da Rabit Guest

    I need to fire an event from a user control and catch it in the parent page.
    I cant seem to find any help in the MSDN etc.
    Any code examples / refrences will help greatly .
    Thanks in advance
    Elrond Bishop
    Da Rabit, Nov 11, 2004
    #1
    1. Advertising

  2. You will have to make an event in your User control and on the page you will
    have to handle it. Check MSDN for event tutorial.

    For each event in your control (user of custom) you have to write this code
    to make it the proper way:

    protected virtual void OnSpecialClick(SpecialEventArgs e)
    {
    SpecialEventHandler specialEvent =
    (SpecialEventHandler)Events[SpecialEvent];
    if (specialEvent != null) specialEvent(this, e);
    }
    private static readonly object SpecialEvent = new object();
    public event SpecialEventHandler SpecialClick
    {
    add { Events.AddHandler(SpecialEvent, value); }
    remove { Events.RemoveHandler(SpecialEvent, value); }
    }


    --
    RobertK
    { Clever? No just smart. }

    "Da Rabit" <> wrote in message
    news:ec#...
    > I need to fire an event from a user control and catch it in the parent

    page.
    > I cant seem to find any help in the MSDN etc.
    > Any code examples / refrences will help greatly .
    > Thanks in advance
    > Elrond Bishop
    >
    >
    Robert Koritnik, Nov 12, 2004
    #2
    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. Marcel Balcarek
    Replies:
    1
    Views:
    5,773
    Ashish M Bhonkiya
    Apr 29, 2004
  2. =?Utf-8?B?U3RldmUgQm9vdGg=?=

    Event fails to fire first time in dynamically loaded user control(

    =?Utf-8?B?U3RldmUgQm9vdGg=?=, Apr 5, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    589
    =?Utf-8?B?U3RldmUgQm9vdGg=?=
    Apr 6, 2005
  3. Chad
    Replies:
    4
    Views:
    8,324
  4. niberhate
    Replies:
    1
    Views:
    1,336
    Cubaman
    Apr 26, 2010
  5. Vannela

    Can we fire a user control event when the user does the action

    Vannela, Nov 10, 2003, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    121
    Vannela
    Nov 10, 2003
Loading...

Share This Page