[英]How to use JQuery dialog as Confirm dialog in ASP.NET?
I am new to jquery and i am trying to open a dialog onclientclick of a button. 我是jquery新手,正在尝试打开onclientclick按钮的对话框。 The dialog is having some text and accept and decline button. 对话框中有一些文本,然后单击接受和拒绝按钮。 On accept, it must do a server postback and and on decline should do nothing. 接受后,它必须执行服务器回发,而拒绝时则不执行任何操作。 Any pointers on this will be highly appreciated 任何对此的指针将不胜感激
I am trying to do the below.. but does not work 我正在尝试执行以下操作..但是不起作用
$(document).ready(function () {
$(function () {
$("#SucessDialog").dialog({
autoOpen: false,
//width: 450,
modal: true,
resizable: false
});
});
function show_confirm()
{
$("#SucessDialog").dialog('open');
}
<asp:Button ID="btnfinance" CssClass="btn green" runat="server" OnClientClick="show_confirm()" OnClick="btnfinance_click" Text="Finance" style="width:25%"></asp:Button>
The JQuery jQuery的
$('#SuccessDialog').
is a selector for an element with id: SuccessDialog. 是ID为:SuccessDialog的元素的选择器。
Make sure you have a 确保您有一个
<div id="SuccessDialog">some buttons</div>
on your page somewhere. 在您页面的某处。
Having pointed out the basics, the show_confirm function doesn't cancel the postback instruction. 指出了基础知识之后,show_confirm函数不会取消回发指令。 You'll need something like: 您将需要以下内容:
OnClientClick="JavaScript: return show_confirm;"
and return false in your show_confirm
function. 并在show_confirm
函数中返回false。
I think you can use an <asp:button...
inside the JQuery dialog. 我认为您可以在JQuery对话框中使用<asp:button...
Just make the confirm point to the postback thats in your Original button. 只需将确认点指向“原始”按钮中的“回发”即可。 If you got this working, you can try to improve the code to have a more general purpose. 如果您能正常工作,则可以尝试改进代码以具有更通用的用途。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.