I am trying to call a function using delegates in a parent form using AddHandler when a button click event is fired within a usercontrol that is on the form.
I have built a test application where I can get this working. The class on the parent form is:
Partial Class _Default
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
AddHandler WebUserControl1.btnHandler, AddressOf test
Public Sub test(ByVal strVacancyID As String)
Response.Write("Called From TEST: " + strVacancyID)
The class on the User Control is:
Partial Class usercontrol_WebUserControl
Public Delegate Sub OnButtonClick(ByVal strVacancyID As String)
Public Event btnHandler As OnButtonClick
Protected Sub btnTest_Click(ByVal sender As Object, ByVal e As EventArgs)
However, in my current project the user control is nested within a gridview, when I try to add the "AddHandler" code the form can't "see" the user control, presumably because it is nested within the gridview.
How can I link the nested usercontrol to the AddHandler?