Catching events in web form fired by user control

Ask a Question related to ASP.NET General, Design and Development.

  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. Similar Questions and Discussions

    1. web user control events
      I have an ascx web user control that has a button and listbox. I want to be able to expose the click event of the button and return the selected...
    2. Events of datagrid in user control not fired
      Hi, I have a user control which contains a datagrid. The page hosting the user control passes to it the values, which the user control transforms...
    3. Know in user control page_load if an user control event is going to be fired
      Hi all, i have built a user control that shows a map and let the user zoom in, out, usual stuff. Putting this object in a webform the user can...
    4. No events are fired in child control
      I have developed a custom web control that may contain any child controls. Now I have a problem that even though I register an event handler on a...
    5. Page Load fired 3 times Web user control is embedded in a custom control
      Hi, I have built a custom control that build a table with 3 cells in it. The custom control is designed to add all child controls to cell#2,...
  3. #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

Posting Permissions

  • You may not post new threads
  • You may 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