【发布时间】:2009-08-30 04:43:55
【问题描述】:
我正在尝试检查位于母版页内的网络表单 (aspx) 页面上的所有复选框,具体取决于复选框的 ID。复选框是动态创建的,所以我只知道找到它的前缀。所以,我需要通过某种方式迭代页面上的控件来找到这些复选框。
下面是应该进行检查的代码:
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Dim oCheckbox As System.Web.UI.WebControls.CheckBox = Nothing
Dim oControl As Control = Nothing
For Each oControl In Me.Controls
If oControl IsNot Nothing Then
If TypeOf oControl Is System.Web.UI.WebControls.CheckBox Then
oCheckbox = oControl
If oCheckbox.Text.StartsWith("ClientCheckBox_") Then
oCheckbox.Checked = True
End If
End If
End If
Next
End Sub
【问题讨论】:
-
看到人们去服务器做这个让我很痛苦...... :(
-
除了痛,你有什么建议吗?
-
其实是的,你用过JavaScript吗?
标签: asp.net vb.net controls webforms web-controls