Professional Web Applications Themes

Catching events in web form fired by user control - ASP.NET General

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...

  1. #1

    Default Catching events in web form fired by user control

    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 Guest

  2. #2

    Default Catching events in web form fired by user control

    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 Guest

Similar Threads

  1. User Control Events
    By Bob Avallone in forum ASP.NET Building Controls
    Replies: 4
    Last Post: May 26th, 05:51 AM
  2. Events of datagrid in user control not fired
    By Emmanuel in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: June 28th, 07:58 AM
  3. Replies: 5
    Last Post: February 24th, 02:07 PM
  4. No events are fired in child control
    By Casper Hornstrup in forum ASP.NET Building Controls
    Replies: 6
    Last Post: January 30th, 09:05 AM
  5. Page Load fired 3 times Web user control is embedded in a custom control
    By Thomas Ekegren in forum ASP.NET Building Controls
    Replies: 0
    Last Post: September 3rd, 05:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139