确认模式按钮 asp.net 的操作
Confirm action for modal button asp.net
当用户单击下面模式上的"取消"按钮时,我正在尝试添加提示。它会提示他们确认操作。下面的代码是我目前尝试的代码。
function ShowAddEditExecutive() {
$("#addEditExecutive").dialog({
modal: true,
width: 800,
appendTo: "form",
open: function () {
$(this).dialog("widget").find(".ui-dialog-titlebar").show();
// Removes the do you want to leave this page dialog.
window.onbeforeunload = null;
// The two isplalines below are 2 different ways to ensure the
// background is completely grayed out if the modal is larger
// then the page. The first was chosen so that the scroll
// bars are not disabled.
$('.ui-widget-overlay').css('position', 'fixed');
//$('body').css('overflow', 'hidden');
},
buttons: {
"Add/Edit Executive Information": function () {
$("[id*=btnAddEditExecutive]").click();
},
"Cancel": function () {
$(this).dialog("close");
}
},
close: function (ev, ui) {
// Ensures when you cancel that the values are not retained.
$(this).remove();
// The two lines below are 2 different ways to ensure the
// background is completely grayed out if the modal is larger
// then the page. The first was chosen so that the scroll
// bars are not disabled.
$('.ui-widget-overlay').css('position', 'absolute');
//$('body').css('overflow', 'inline');
},
});
}
如果要创建本机方法来确认操作,可以使用confirm
提示用户选择继续或不继续,这是您应该在代码中执行的操作
"Cancel": function () {
if(confirm("Are you sure you want to cancel ?"))
{
//code if yes
$(this).dialog("close");
}
else
{
//code if no, don't do anything in your case, or don't use the else
}
}
下面是使用示例。
另一种方式,如果你想让它看起来与你的设计相同,你可以创建一个自定义<div>
,其中包含用户是否同意或想要继续的确认文本,然后使用CSS
并使用jQuery onclick function
来处理事件style
它。
相关文章:
- 使用查询将对象数组发布到asp.net-mvc控制器操作的正确方法是什么
- 如何在asp.net mvc 3上进行触摸屏操作
- 为什么在ASP.NET Ajax更新面板中执行任何操作后javascript元素都停止工作
- ASP.Net MVC 脚本无法使用控制器的默认操作 URL.使用控制器/操作 URL 也是如此
- asp.net mvc操作方法发布除json数据之外的数据
- ASP.NET MVC:2d数组在从javascript传递到MVC控制器操作后为null
- 如何将JavaScript文件路径映射到ASP.Net MVC控制器操作
- 根据用户在asp.net网站中选择的弹出窗口使用JavaScript操作网页
- asp.net Web API 405 方法不允许、发布、自定义操作
- ASP.Net JavaScript 表的 MVC 操作链接/URL 操作 - datatable.net
- 使用 JavaScript 调用重定向到具有 asp.net MVC 应用程序的操作
- ASP.Net:跨浏览器操作
- ASP.NET 对同步 AJAX 请求的 MVC 操作
- 从单独的 javascript 文件中调用 ASP.NET MVC 控制器操作
- 使用 Java 脚本操作 asp.net 控件
- 在asp.net anypostback之前执行javascript操作
- 在ASP.NET MVC3剃刀上使用javascript变量动态创建html操作链接
- AngularJS$http://.NET Web API-获取400(错误请求)或NULL POST操作方法参数
- ASP.NET MVC操作未获取参数值
- 如何在ASP.NET MVC中中止操作