0
我正在使用vb.net我已將html複選框runat服務器和鏈接按鈕單擊事件我想訪問此複選框我已嘗試checkbox.checked但總是返回false 上鍊接按鈕點擊Checkbox1.checked返回false vb.net
If ckice.Checked = True Then
ckice.Value = "Yes"
Else
ckice.Value = "No"
End If
我正在使用vb.net我已將html複選框runat服務器和鏈接按鈕單擊事件我想訪問此複選框我已嘗試checkbox.checked但總是返回false 上鍊接按鈕點擊Checkbox1.checked返回false vb.net
If ckice.Checked = True Then
ckice.Value = "Yes"
Else
ckice.Value = "No"
End If
使用這樣的代碼:
<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>
在後端:
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
我試過這個..不工作 –
你的html和PageLoad事件代碼在哪裏? – Kaf
測試它,當代碼在Button_Click中時 - 它正確地檢測到真/假。你禁用視圖狀態? –
–