C
Craig Douthitt via DotNetMonster.com
I am trying to capture an buttonclick on a usercontrol in the webform the usercontrol resides in. After researching this issue, I've come to believe that the best way of handling this is by raising an event in the control and consuming the event in the webform. I tried the following, unfortunatly while the usercontrol raises the event the webform method does not react.
UserControl (Named WebUserControl1 contains one button)
Public Delegate Sub MyEvtHandler(ByVal sender As Object, ByVal e As EventArgs)
Public Event SaveClick As MyEvtHandler
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RaiseEvent SaveClick(sender, e)
End Sub
WebForm
Protected WithEvents ctrl As WebUserControl1
Private Sub handleclick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctrl.SaveClick
Response.Write("Handled")
End Sub
Is there anything else that needs to be set to cause the webform to consume the click event. I am new to ASP so my apologies in advance if the solution is simple.
UserControl (Named WebUserControl1 contains one button)
Public Delegate Sub MyEvtHandler(ByVal sender As Object, ByVal e As EventArgs)
Public Event SaveClick As MyEvtHandler
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RaiseEvent SaveClick(sender, e)
End Sub
WebForm
Protected WithEvents ctrl As WebUserControl1
Private Sub handleclick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctrl.SaveClick
Response.Write("Handled")
End Sub
Is there anything else that needs to be set to cause the webform to consume the click event. I am new to ASP so my apologies in advance if the solution is simple.