【发布时间】:2014-08-24 08:18:02
【问题描述】:
我想创建一个只有一个图像/按钮的页面。当你点击它时。 它会出现一个弹出窗口,里面有几个复选框。我想在选中时将复选框的值传递给标签。
但是当我单击复选框时,复选框的 CHECKEDCHANGED 事件从未发生。那是y我尝试放置一个按钮,如果我们按下按钮,调试器将始终将值显示为FALSE。 按钮的点击事件将发生,但它只会将复选框值显示为 FALSE。 请查看图像、代码,如果需要,我可以提供 JS 和 CSS。
默认.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 Class
JS:
$('#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();
}
}]
});
});
【问题讨论】: