Find control. This is used for finding a control nested on an asp.net page.
Public Function FindMyControl(parentControl As Control, controlName As String) As Control
If (Not parentControl Is Nothing And parentControl.HasControls()) Then
Dim c As Control
c = parentControl.FindControl(controlName)
If (Not c Is Nothing) Then
Return c
End If
'if arrived here, then not found on this level, so search deeper
'loop through collection
For Each ctrl As Control In From ctrl1 As Control In parentControl.Controls Where (ctrl1.HasControls())
Dim c2 As Control
c2 = FindMyControl(ctrl, controlName)
If (Not c2 Is Nothing) Then
Return c2 'found it!
End If
Next
End If
Return Nothing 'found nothing (in this branch)
End Function