Catching events in web form fired by user control

Discussion in 'ASP .Net' started by Nick Lewis, Aug 1, 2003.

  1. Nick Lewis

    Nick Lewis Guest

    I'm trying to process an event raised by a user control in the web
    form
    that contains that control. I've fathomed out how to handle the event
    within the control but how can I then pass it on to the parent web
    form?

    Thanks,

    Nick
     
    Nick Lewis, Aug 1, 2003
    #1
    1. Advertising

  2. You have a couple of ways of doing this. You can either
    bubble the even using the RaiseBubbleEvent method in the
    user control and overriding the OnBubbleEvent method in
    the WebForm, or you can explicitly declare and raise an
    event from your user control and catch it in your WebForm.
    For example, if you wanted to ripple a Button click...

    In UserControl:
    ....
    Public Event SaveClicked(ByVal sender As Object, ByVal e
    As System.EventArgs)
    ....
    Private Sub btnSave_Click(ByVal sender As Object, ByVal e
    As System.EventArgs) Handles btnSave.Click
    RaiseEvent SaveClicked(sender, e)
    End Sub


    In WebForm:

    Private Sub MyUserControl_SaveClicked(ByVal sender As
    Object, ByVal e As System.EventArgs) Handles
    MyUserControl.SaveClicked
    'Do Something...
    End Sub

    That should work (although I've just type it from memory,
    so there may be some syntax errors or typos...)

    >-----Original Message-----
    >I'm trying to process an event raised by a user control

    in the web
    >form
    >that contains that control. I've fathomed out how to

    handle the event
    >within the control but how can I then pass it on to the

    parent web
    >form?
    >
    >Thanks,
    >
    >Nick
    >.
    >
     
    Gary McCormack, Aug 1, 2003
    #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. Samuel
    Replies:
    2
    Views:
    602
    Samuel
    Apr 5, 2009
  2. Thomas Ekegren

    Page Load fired 3 times Web user control is embedded in a custom control

    Thomas Ekegren, Sep 3, 2003, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    238
    Thomas Ekegren
    Sep 3, 2003
  3. Fabrizio
    Replies:
    5
    Views:
    260
    Alessandro Zifiglio
    Feb 24, 2004
  4. Emmanuel

    Events of datagrid in user control not fired

    Emmanuel, Jun 28, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    107
    Emmanuel
    Jun 28, 2004
  5. Justin

    How do I capture events fired in child user controls?

    Justin, Jan 27, 2004, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    252
    Justin
    Jan 27, 2004
Loading...

Share This Page