读书人

怎么判断文本框控件是否存在

发布时间: 2012-06-13 12:30:18 作者: rapoo

如何判断文本框控件是否存在
前端代码如下:<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 

读书人网 >asp.net

热点推荐