すべてのコントロールとその親/子をループする方法はありません。例えば
:
Public Module ExtensionMethods
<Runtime.CompilerServices.Extension()> _
Public Function FindControlRecursively(ByVal parentControl As System.Web.UI.Control, ByVal controlType As Type) As System.Web.UI.Control
If parentControl.GetType = controlType Then
Return parentControl
End If
For Each c As System.Web.UI.Control In parentControl.Controls
Dim child As System.Web.UI.Control = FindControlRecursively(c, controlType)
If child IsNot Nothing Then
Return child
End If
Next
Return Nothing
End Function
End Module
、あなたはそれを確認することができます。
If Not FindControlRecursively(Me.Page.Master, GetType(UC_Status)) Is Nothing Then
'thow exception or whatever'
End If
注:すべてのテストされていない
素晴らしい、ありがとうTim。それは私が探しているようです。 – cschear