I am having a problem in getting a "FindControl" method to work in my PageLoad event. I need to find the control that raise an event in the PageLoad event.
The FindControl is not finding anthing. I just get "Object reference not set to an instance of an object." Any ideas on what is wrong? BTW this PL event is operating within a User Control on a Page with also has a Master Page.
Please see the attached code. "cntControl" seems to stay at nothing although a value is in "ctrlname"
Thanks in advance,
Dim ctrlname As String = Page.Request.Params.Get("__EVENTTARGET")
Dim cntControl As Control = Nothing
Dim strID As String = ""
Dim lbtn As LinkButton = Nothing
If Not (ctrlname Is Nothing) And (ctrlname <> String.Empty) Then
cntControl = Me.Page.FindControl(ctrlname)
lbtn = DirectCast(cntControl, LinkButton)
If lbtn.CommandName = "AddRow" Then
ElseIf lbtn.CommandName = "Delete" Then
response.write("Something Else triggered")
response.write("No control was triggered")