html - VB.NET Control.find 控件查找指定容器外的控件
问题描述
我正在维护一个旧的 aspx 系统,它使用一个函数来识别是否在 aspx 页面中创建了动态控件。不过,它似乎是在指定容器之外找到控件。有没有人以前出现过这种情况,或者知道为什么会发生这种情况?
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
我传入一个带有 runat 服务器的 HTML div 作为容器,然后我知道的下拉列表的名称位于 div 之外。但 controlExists 返回 true,即使它应该为 false。
解决方案
推荐阅读
- c# - 在链表中如果我传递对象数据然后搜索代码不起作用
- django - 从 django settings.py 访问 javascript 中的 API 密钥
- javascript - Sequelize - bulkInsert 排除任何已经存在的条目
- html - Flex 显示为按钮提供自动高度
- javascript - 在 REACT 中更改动态生成的组件的类别而不为每个组件手动创建单独的状态?
- android - 如何在 Flutter 中用 CircleAvatar 替换抽屉的汉堡包图标?
- list - Haskell 列表理解创建所有可能的值组合
- python - 熊猫从变量中读取excel
- c - 函数指针原型,它以三个整数指针作为参数并返回字符指针
- javascript - 函数的默认解构参数