Html VB.NET Control.find控件查找指定容器外部的控件
我正在维护一个旧的aspx系统,该系统使用一个函数来标识是否在aspx页面中创建了动态控件。但它似乎在指定容器之外找到控件。以前有没有人见过这种情况,或者知道为什么会发生这种情况Html VB.NET Control.find控件查找指定容器外部的控件,html,asp.net,Html,Asp.net,我正在维护一个旧的aspx系统,该系统使用一个函数来标识是否在aspx页面中创建了动态控件。但它似乎在指定容器之外找到控件。以前有没有人见过这种情况,或者知道为什么会发生这种情况 Public Shared Function controlExists(ByVal container As Control, ByVal controlname As String) As Boolean Dim Control As Control = Nothing cont
Public Shared Function controlExists(ByVal container As Control, ByVal controlname As String) As Boolean
Dim Control As Control = Nothing
controlExists = True
Try
Control = container.FindControl(controlname)
If IsNothing(Control) Then
controlExists = False
End If
Catch ex As Exception
Throw ex
End Try
End Function
我传入一个HTML Div,其中有一个runat服务器作为容器,然后我知道一个下拉列表的名称位于该Div之外。但是controlExists返回true,即使它应该是false