I have a .NET 4.0 Web Application project written in VB. I have a Master Page from which all subsequent webpages are derived. Each webpage comprises of one or more Web User Controls. One particular WUC comprises of a Panel that the user can click on - it acts and feels like a button - taking them to another page of relevant data.
I now need to capture the OnClick event of the panel and carry out a task before redirecting the user to another page. The solution I have tried so far includes:
(1) Insert the following code after the Partial Class... opening statements on the WUC:
Public Event Click(ByVal sender As Object, ByVal e As EventArgs)
Protected Overridable Sub OnClick(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Click
RaiseEvent Click(Me, e)
End Sub
(2) Include the following subroutine within the WUC:
Public Sub common_button1_Click1(sender As Object, e As EventArgs) Handles Me.Click
' Do Stuff here
End Sub
(3) Have the following statement within the Page_Prerender subroutine of the WUC:
AddHandler Me.Click, AddressOf common_button1_Click1
How do I now use this event handler, so that when I click on the WUC it fires? I was thinking that the reference to the WUC on my webpage would have the attribute 'OnClick' within it and point to 'common_button1_Click', but the option does not appear to be within the IntelliSense of Visual Studio. Example ...
Many thanks in anticipation of your responses.