1

我正在使用 vb.net 我有 html 复选框 runat 服务器和链接按钮单击事件我想访问此复选框我尝试过 checkbox.checked 但这总是在链接按钮单击时返回 false

If ckice.Checked = True Then
    ckice.Value = "Yes"
Else
    ckice.Value = "No"
End If
4

1 回答 1

0

使用这样的代码:

<div>
<input id="Check1"  type="checkbox" runat="server" checked="checked"/> 
        CheckBox1 &nbsp;&nbsp;
    <span id="Span1" style="color:red" runat="server" />
    <br />
    <input type="button" id="Button1" value="Enter"
           onserverclick="Button1_Click" runat="server"/>
</div>

在后端:

Sub Button1_Click(ByVal Source As Object, ByVal e As EventArgs)
    If Check1.Checked = True Then
        Span1.InnerHtml = "Check1 is checked!"
        Check1.Value = "Yes"
    Else
        Span1.InnerHtml = "Check1 is not checked!"
        Check1.Value = "No"
    End If
End Sub
于 2013-10-15T17:19:21.983 回答