![]() |
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 |
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 >. > |
| All times are GMT. The time now is 12:54 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.