单击jquery对话框OK按钮后执行c#代码
我有一个asp.net网页,其中有一个搜索按钮。单击该按钮时,会出现一个jquery对话框,用户必须确认是否要继续或取消。如果单击“确认”按钮,则必须继续执行搜索按钮后面的c代码,如果单击“取消”,则,对话框必须关闭,否则不会发生任何其他情况单击jquery对话框OK按钮后执行c#代码,jquery,jquery-dialog,Jquery,Jquery Dialog,我有一个asp.net网页,其中有一个搜索按钮。单击该按钮时,会出现一个jquery对话框,用户必须确认是否要继续或取消。如果单击“确认”按钮,则必须继续执行搜索按钮后面的c代码,如果单击“取消”,则,对话框必须关闭,否则不会发生任何其他情况 $(document).ready(function () { $("#<%=butSearch.ClientID%>").click(function (e) { // Button which will activa
$(document).ready(function () {
$("#<%=butSearch.ClientID%>").click(function (e) { // Button which will activate our modal
$('#modal').reveal({ // The item which will be opened with reveal
animation: 'fade', // fade, fadeAndPop, none
animationspeed: 600, // how fast animtions are
closeonbackgroundclick: true, // if you click background will modal close?
dismissmodalclass: 'close' // the class of a button or element that will close an open modal
});
return false;
});
});
<div id="modal">
<div id="heading">
Search Notification
</div>
<div id="content">
<p>Please be aware that any search via the xxxx, will incur a cost. Do you wish to proceed?</p>
<a href="#" class="button green close"><img src="../../Imgs/dialog_tick.png">Proceed</a>
<a href="#" class="button red close"><img src="../../Imgs/dialog_cross.png">Cancel</a>
</div>
</div>
$(文档).ready(函数(){
$(“#”)。单击(函数(e){//按钮,该按钮将激活我们的模式
$('#model')。显示({//将使用显示打开的项目
动画:“fade',//fade,fadeAndPop,无
动画速度:600,//动画有多快
closeonbackgroundclick:true,//如果单击background将关闭吗?
dismissmodalclass:'close'//将关闭打开模式的按钮或元素的类
});
返回false;
});
});
搜索通知
请注意,通过xxxx进行的任何搜索都将产生费用。你想继续吗
假设我正在查看,似乎没有任何选项可以传递到此插件以对配置的关闭按钮做出不同的响应
但是,没有理由不将事件附加到您感兴趣执行其他操作的按钮上。在您的情况下,我认为这是“继续”按钮,您希望对服务器进行ajax调用:
$('#modal .button.green.close').click(function(){
$.ajax(...)
});
在该示例中,
$.ajax
可以替代任何jquery ajax方法。好的,您可以先尝试一下,确保将模式弹出窗口附加到其中
表单,然后简单地使用jQuery提交表单,以防用户单击“继续”
$(document).ready(function () {
$("#<%=butSearch.ClientID%>").click(function (e) { // Button which will activate our modal
$('#modal').reveal({ // The item which will be opened with reveal
animation: 'fade', // fade, fadeAndPop, none
animationspeed: 600, // how fast animtions are
closeonbackgroundclick: true, // if you click background will modal close?
dismissmodalclass: 'close' // the class of a button or element that will close an open modal
});
jQuery("#modal").parent().appendTo(jQuery("form:first")); // This will append the dialog to the form ensuring values are sent during postback.
return false;
});
});
<div id="modal">
<div id="heading">
Search Notification
</div>
<div id="content">
<p>Please be aware that any search via the xxxx, will incur a cost. Do you wish to proceed?</p>
<a href="#" id="anchorProceed" onclick="javascript:proceed()" class="button green close"><img src="../../Imgs/dialog_tick.png">Proceed</a>
<a href="#" id="anchorCancel" class="button red close"><img src="../../Imgs/dialog_cross.png">Cancel</a>
</div>
但是实际的问题是什么?模态弹出与此有什么关系?我的实际问题是,在模态弹出对话框上的确认按钮被点击后,我如何让代码继续执行?模态弹出除了确认之外,没有其他内容吗?您可能必须将accept与Ajax调用相链接,它调用一个C#脚本来完成操作的结果,或者如果你可以编辑的话,在模式中调用一个
。非常感谢Tariq。当我滑动“继续”按钮时,它似乎没有提交表单。有没有办法在原始搜索按钮的单击事件后面继续执行代码,函数“继续”(){var formId=$('form').attr('id');$(formId).submit();}你必须将你的表单id放在这个'yourFormID',它不起作用吗?这就是你上面所做的是的,这就是我正在做的,但是提交不起作用。谢谢。
function proceed(){
$( "#yourFormID" ).submit();
}