Fürs Archiv:
Public Shared Function FindControlRecursive(ByVal Root As Control, ByVal FindID As String) As Control
Dim foundctl As Control
If Root Is Nothing Then Return Nothing
If Root.ID = FindID Then Return Root
For Each ctl As Control In Root.Controls
foundctl = FindControlRecursive(ctl, FindID)
If foundctl IsNot Nothing Then
Return foundctl
End If
Next
Return Nothing
End Function
Public Shared Function FindControlInAllParents(ByVal Root As System.Web.UI.Control, ByVal FindID As String) As System.Web.UI.Control
Dim temp As System.Web.UI.Control = Nothing
While Root IsNot Nothing
temp = FindControlRecursive(Root, FindID)
If temp Is Nothing Then
Root = Root.Parent
Else
Root = Nothing
End If
End While
Return temp
End Function