确认删除asp.net中的弹出框 [英] Confirm Delete Pop up Box in asp.net
本文介绍了确认删除asp.net中的弹出框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个删除aspx按钮,但我需要先弹出一个确认.如果单击是",则需要触发后面的代码以进行委托;如果单击否",则需要取消操作.有任何想法吗?
I have a delete aspx button but i need to popup a confirm first. if clicked yes, then I need to trigger the code behind for deleition, if clicked no, I need to cancel operation. any idea?
推荐答案
,您可以使用 javascript确认 [^ ]
you can use a javascript confirm[^]
<asp:Button ID="Button1" runat="server" OnClientClick="javascript:confirm(''Are you sure?'');" />
看看这个使用jQuery和jQuery.alerts的示例站点
示例网站源代码 [
Have a look at this example site that uses jQuery and jQuery.alerts
Example Site Source Code[^]
The wrapper function in the DialogTest.js file lets you do exactly this sort of functionality
var DialogTest = {};
DialogTest.doConfirm = function (source, message, title) {
jConfirm(message, title, function(r) {
if (r == true) {
__doPostBack(source.id, '');
}
});
return false;
};
在页面加载中,按如下所示连接要具有确认此功能"的所有按钮.
In your page load, wire up any buttons you want to have ''confirm this'' functionality as follows
if (!Page.IsPostBack)
{
this.deleteButton.Attributes.Add("onclick",
"return DialogTest.doConfirm(this, 'Are you sure you want to delete?', 'Confirm Delete');");
}
单击按钮后,您现在将看到一个确认"(确定\取消)对话框.如果单击确定",则表单将回发到普通的aspx事件处理程序.如果单击取消",则不会发生回发.
When you click the button, you''ll now see a ''confirm'' (OK \ Cancel) dialog box. If you click OK, the form will postback to the normal aspx event handler. If you click Cancel, no postback occurs.
这篇关于确认删除asp.net中的弹出框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文