我想创建一个只有一个图像/按钮的页面。当你点击它时。它将出现一个弹出窗口,里面有几个复选框。当复选框被选中时,我希望将复选框的值传递给标签。
但是当我单击复选框时,复选框的CHECKEDCHANGED事件永远不会发生。也就是说,我试着放置一个按钮,在选中复选框之后,如果我们按下按钮,调试器将始终将该值显示为FALSE。按钮的单击事件将发生,但它将仅将复选框值显示为FALSE。请看看图像,代码,我可以提供JS和CSS,如果你想。

default.aspx:
<body style="background-color: #FFFF00">
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<a id="open-pop-up-2" href="#pop-up-2">
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="images/234.png"/>
</a>
</td>
</tr>
</table>
</div>
<div id="pop-up-2" class="pop-up-display-content">
<table style="width:100%;border-style:solid;border-width:1px">
<tr>
<td>
<asp:CheckBox ID="CheckBox1" runat="server" Text="Onion" />
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Show State" UseSubmitBehavior="false"/>
</td>
</tr>
</table>
</div>
</form>
default.aspx.vb:
Imports System.Web.UI
Imports System.Web
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Dim dt1 As New DataTable
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If CheckBox1.Checked = True Then
MsgBox("State: Checked")
ElseIf CheckBox1.Checked = False Then
MsgBox("State: Unchecked")
End If
End Sub
Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
MsgBox("State: Checked")
ElseIf CheckBox1.Checked = False Then
MsgBox("State: Unchecked")
End If
End Sub
End ClassJS:
$('#open-pop-up-2').click(function (e) {
e.preventDefault();
$('#pop-up-2').popUpWindow({
action: "open",
buttons: [{
text: "Yes",
click: function () {
this.close();
}
}, {
text: "No",
click: function () {
this.close();
}
}]
});
});发布于 2014-08-24 16:54:19
checkbox必须具有AutoPostBack="True",否则在另一个控件导致回发之前不会激发change事件。
<asp:CheckBox ID="CheckBox1" runat="server" Text="Onion" AutoPostBack="true" />发布于 2014-11-06 15:47:22
我在同一个线程中工作了很长时间,终于得到了由于棘手的弹出代码JQ,复选框状态的值永远不会通过,即使我们设置AUTOPOSTBACK为真或假。因此,我不得不更改弹出窗口控件,并开发自己的控件。
不过还是要谢谢你。
https://stackoverflow.com/questions/25469832
复制相似问题