On page_Init
, I am creating number of UpdatePanel
s and inside these UpdatePanel
s one Panel
in each. I then use this panel to further go ahead and add other controls dynamically. For example I add number of TextBoxe
s and Button
s in each of these Panels. Further, I am binding a click event to all the buttons that are created dynamically. The AddressOf
these click events are in another class called Events. In the Sub from the Event class, when I try to find a control, It does not seem to work.
Here is the code in the EVENT Class
Public Class Events
Inherits System.Web.UI.Page
Public Sub Dynamic_Btn_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim SQL As New SQLControl
Dim sTempPanel1 As UpdatePanel = FindControl("MyUpdatePanel1")
MsgBox("MyUpdatePanel1" & ":" & (sTempPanel1 Is Nothing))
End Sub
End Class
NOTE : If the same above sub is copy / pasted to the code behind of the page class, it works.
I know I am missing some link here. May be the FindControl
is not being referenced to the page in which is should search in.