问题
i am working with vb.net i have take html checkbox runat server and on link button click event i want to access this checkbox i have tried checkbox.checked but this always returns false on link button click
If ckice.Checked = True Then
ckice.Value = "Yes"
Else
ckice.Value = "No"
End If
回答1:
Use code like this:
<div>
<input id="Check1" type="checkbox" runat="server" checked="checked"/>
CheckBox1
<span id="Span1" style="color:red" runat="server" />
<br />
<input type="button" id="Button1" value="Enter"
onserverclick="Button1_Click" runat="server"/>
</div>
On Back End:
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
来源:https://stackoverflow.com/questions/19386453/checkbox1-checked-returns-false-vb-net