本文转自:http://www.aspsnippets.com/Articles/jQuery-UI-Dialog-Modal-Popup-Yes-No-Confirm-example-in-ASPNet.aspx
In this article I will explain with an example, how to use jQuery UI Dialog Modal Popup as Yes No Confirmation Box in ASP.Net using C# and VB.Net.
The jQuery UI Dialog Modal Popup can be configured to work as the JavaScript Yes No Confirmation Box by using Custom Buttons.
HTML Markup
The following HTML Markup consists of jQuery UI Script and CSS files inherited to use jQuery UI Dialog Modal Popup box, an HTML DIV and an ASP.Net Button with UseSubmitBehavior property set to False.
Inside the jQuery document ready event handler, the jQuery UI Dialog Modal Popup box is initialized and the Delete Button is assigned the jQuery click event handler.
The jQuery UI Dialog Modal Popup box has two Custom Buttons i.e. Yes and No. When the Yes Button is clicked, the rel attribute of the Delete button is set to value delete and the click event of the Delete Button is triggered.
And when the No Button is clicked, the jQuery UI Dialog Modal Popup box is closed using the “close” command.
When the Button is clicked, if the rel attribute does not have value delete, the jQuery UI Dialog Modal Popup box is opened using the “open” command, else using the __doPostBack function, the Sever Side event handler of the Button is triggered.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/blitzer/jquery-ui.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function () {
$("[id*=btnDelete]").removeAttr("onclick");
$("#dialog").dialog({
modal: true,
autoOpen: false,
title: "Confirmation",
width: 350,
height: 160,
buttons: [
{
id: "Yes",
text: "Yes",
click: function () {
$("[id*=btnDelete]").attr("rel", "delete");
$("[id*=btnDelete]").click();
}
},
{
id: "No",
text: "No",
click: function () {
$(this).dialog('close');
}
}
]
});
$("[id*=btnDelete]").click(function () {
if ($(this).attr("rel") != "delete") {
$('#dialog').dialog('open');
return false;
} else {
__doPostBack(this.name, '');
}
});
});
</script>
<asp:Button ID="btnDelete" runat="server" Text="Delete" OnClick="DeleteRecord" UseSubmitBehavior="false" />
<div id="dialog" style="display: none" align="center">
Do you want to delete this record?
</div>
Server Side Code
When the Yes option is clicked inside the jQuery UI Dialog Modal Popup box, the following event handler is raised which simulates deletion of record.
C#
protected void DeleteRecord(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Record Deleted.')", true);
}
VB.Net
Protected Sub DeleteRecord(sender As Object, e As EventArgs)
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('Record Deleted.')", True)
End Sub
Screenshot
Browser Compatibility
The above code has been tested in the following browsers.
- API分析——Jquery UI Dialog
1.阅读API文档的一般方法? 通常地, API由三部分构成:属性.方法.事件. 属性表示参数配置,作为一个组件的微调,或者功能的开启与关闭: 方法表示组件能够发生的动作,或者组件的状态监测: 事件表 ...
- jQuery UI dialog 的使用
今天用到了客户端的对话框,把 jQuery UI 中的对话框学习了一下. 准备 jQuery 环境 首先,我们创建一个按钮,点击这个按钮的时候,将会弹出一个对话框. 1 <input type= ...
- jQuery UI dialog 參数说明
前段时间碰到个问题 jquery UI dialog弹出层 弹出多个层是 比方弹出两个层A和B B层假设显示的数据表格太大,伸到了A层的外面,那伸到A层之外的部分就看不到了,由于B层是在A层上弹出的 ...
- Jquery - UI - Dialog(转)
jQuery UI Dialog常用的参数有: 1.autoOpen:默认true,即dialog方法创建就显示对话框 2.buttons:默认无,用于设置显示的按钮,可以是JSON和Array形式: ...
- jQuery UI dialog 参数说明
前段时间碰到个问题 jquery UI dialog弹出层 弹出多个层是 比如弹出两个层A和B B层如果显示的数据表格太大,伸到了A层的外面,那伸到A层之外的部分就看不到了,因为B层是在A层上弹出的 ...
- 解决Select2控件不能在jQuery UI Dialog中不能搜索的bug
本文使用博客园Markdown编辑器进行编辑 1.问题呈现 项目中使用了jQuery UI的Dialog控件,一般用来处理需要提示用户输入或操作的简单页面.逻辑是修改一个广告的图片和标题. 效果截图如 ...
- JQuery UI dialog 弹窗实例及参数说明
按钮代码: <a id="suprise" style="margin-left: 0.5em;cursor:pointer;">点我会有惊喜< ...
- jQuery UI dialog
初始化参数 对于 dialog 来说,首先需要进行初始化,在调用 dialog 函数的时候,如果没有传递参数,或者传递了一个对象,那么就表示在初始化一个对话框. 没有参数,表示按照默认的设置初始化对话 ...
- jQuery UI dialog插件出错信息:$(this).dialog is not a function
使用jQuery UI 1.7.2 dialog插件,遇到这样的错误: [img]http://dl.iteye.com/upload/attachment/308166/97c428e4-2ce2- ...
随机推荐
- jquery 字符串转dom对象及对该对象使用选择器查询
<script> $(document).ready(function () { var htmlStr = '<div id="outerDiv">< ...
- ActiveReports 报表应用教程 (3)---图表报表
ActiveReports 的图表控件支持绝大多数常用的二维和三维图表类型,包括XY图表和财务图表.通过使用图表控件的定制功能,如修改坐标轴.图注.图例等,用户可以创建任何其所需要的图表效果.用户还可 ...
- 不要迷恋那些没技术含量的Linux发行版
昨天悲剧了,重装系统,一个手贱点了替换原系统,分区全给删了,将近三天的工作成果没有了.
- 比较偏门的JVM语言Quercus - PHP on JVM
其实,我不确定Quercus是否可以被认定为一门JVM语言:其次Quercus这个东东分开源版与商业版,开源版只能解释执行.而商业版能编译成Java字节码. 但我知道国内,阿里巴巴很早就在使用它,当然 ...
- php实现添加图片水印
实际运行时需要开启php 的gd2功能,运行环境php4.0以上(demo中的路径改为实际路径) <?php/*打开图片*/ //1.配置图片路径 $src="image/61.jpg ...
- Scala underscore的用途
_ 的用途 // import all import scala.io._ // import all, but hide Codec import scala.io.{Codec => _, ...
- CentOS 编译安装 MySQL5.7
下载 所有版本下载地址: http://dev.mysql.com/downloads/mysql/ 此处用 5.7.10 wget http://dev.mysql.com/get/Download ...
- android ArrayAdapter BaseAdapter SimpleAdapter使用讲解
不是我针对谁,我只想针对新手玩家. 不清楚Adapter作用的可以看一下http://www.cnblogs.com/zhichaobouke/p/5798672.html (括号里的内容都是我主观添 ...
- MSCRM 仪表盘 控件 数量 更改(Change the maximum no. of controls on MSCRM Dashboards )
The maximum number of controls allowed on MSCRM dashboards are 6. You cannot put the more than 6 gra ...
- Oracle EBS在编码方式为AL32UTF8时的注意事项
现如今的EBS系统中,为了推进国际化的进程,以及系统向全球化的扩展,在Oracle数据库的编码方式上渐渐从支持中国本土简体中文的ZHS16GBK转向了更趋于国际化的AL32UTF8编码方式.但随之而来 ...