For what it's worth, you could use this extension method which searches all child controls:
Module ControlExtensions
<Runtime.CompilerServices.Extension()>
Public Function FindControlPart(root As Control, IdStart As String) As Control
Dim controls As New Stack(Of Control)(root.Controls.Cast(Of Control)())
While controls.Count > 0
Dim currentControl As Control = controls.Pop()
If currentControl.ID.StartsWith(IdStart, StringComparison.InvariantCultureIgnoreCase) Then
Return currentControl
End If
For Each child As Control In currentControl.Controls
controls.Push(child)
Next
End While
Return Nothing
End Function
End Module
Usage:
Dim control As Control = Page.FindControlPart(part1)
It returns the first control which start with a given ID-Part. So it's possible that you get the wrong. It's less error-prone if you use the correct NamingContainer
instead of the Page
as root.