Skip to content

Instantly share code, notes, and snippets.

@anova
Created July 25, 2014 19:40
Show Gist options
  • Save anova/c9b8d4b3ee7af9a8a8a1 to your computer and use it in GitHub Desktop.
Save anova/c9b8d4b3ee7af9a8a8a1 to your computer and use it in GitHub Desktop.
''' <summary>
''' Finds a Control recursively. Note finds the first match and exists
''' </summary>
''' <param name="ContainerCtl"></param>
''' <param name="IdToFind"></param>
''' <returns></returns>
Public Shared Function FindControlRecursive(Root As Control, Id As String) As Control
If Root.ID = Id Then
Return Root
End If
For Each Ctl As Control In Root.Controls
Dim FoundCtl As Control = FindControlRecursive(Ctl, Id)
If FoundCtl IsNot Nothing Then
Return FoundCtl
End If
Next
Return Nothing
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment