前端代码如下:<input id='b1' ReadOnly='true' value='0' style='width:80px;' runat="server" />
我在后台如何判断是否存在 id='b1' 的input?
------解决方案--------------------------------------------------------
遍历页面,标签是input的。。。
------解决方案--------------------------------------------------------
或者form1.FindControl(“id”)看看是不是空
------解决方案--------------------------------------------------------
- VB.NET code
Dim bool As Boolean = False For Each item In Me.Controls If item.GetType.ToString = "System.Web.UI.HtmlControls.HtmlInputText" Then Dim control = TryCast(item, System.Web.UI.HtmlControls.HtmlInputText) If control.ID = "b1" Then bool = True Exit For End If End If Next