【发布时间】:2015-05-04 02:25:20
【问题描述】:
我正在使用一个名为 bPopup (http://dinbror.dk/bpopup/) 的简单开箱即用的 jQuery 脚本在 .net Web 表单上启动模态弹出窗口。我对 jQuery 有点陌生,我想要的行为是在按钮单击上的代码隐藏事件完成处理后触发模式弹出。在模态弹出元素中,我有两个面板,一个带有成功消息,一个带有失败消息。我将脚本绑定到按钮,问题是,它只是触发 jquery 而不再触发代码隐藏事件。
这里是jQuery脚本(相对于作者的demo复制粘贴):
<script>
// Semicolon (;) to ensure closing of earlier scripting
// Encapsulation
// $ is assigned to jQuery
; (function ($) {
// DOM Ready
$(function () {
// Binding a click event
// From jQuery v.1.7.0 use .on() instead of .bind()
$('#my-button').bind('click', function (e) {
// Prevents the default action to be triggered.
e.preventDefault();
// Triggering bPopup when click event is fired
$('#element_to_pop_up').bPopup();
});
});
})(jQuery);
</script>
这里是模态弹出元素:
<!-- Element to pop up -->
<div id="element_to_pop_up">
<asp:Panel ID="pnlSubmitSuccess" runat="server" Visible="true">
<div style="font-size:25px; font-weight:bold; font-style: italic; color:#4d90fe;">Success!</div><br /><br />
<div style="font-size:20px;">The submitted data was successfully saved.</div>
</asp:Panel>
<asp:Panel ID="pnlSubmitFail" runat="server" Visible="false">
<div style="font-size:25px; font-weight:bold; font-style: italic; color:#4d90fe;">Whoops!</div>
<br /><br /><div style="font-size:20px;">There seems to be a few issues with the data you submitted. Please check all required fields for accuracy.</div>
</asp:Panel>
</div>
这是它附加的按钮:
<asp:Button ID="btnProcess" runat="server" Text="Process" CssClass="button"
onclick="btnProcess_Click" />
onclick 事件永远不会发生,无论发生什么,jquery 都会弹出模式。我该如何解决这个问题?
【问题讨论】:
标签: javascript c# jquery asp.net .net