本文转自: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.
 
In this scenario the jQuery UI Dialog Modal Popup box makes of Custom Buttons, to read more about it please refer my article jQuery UI Dialog Modal Popup Custom Buttons example.
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.

[转]jQuery UI Dialog Modal Popup Yes No Confirm example in ASP.Net的更多相关文章

  1. API分析——Jquery UI Dialog

    1.阅读API文档的一般方法? 通常地, API由三部分构成:属性.方法.事件. 属性表示参数配置,作为一个组件的微调,或者功能的开启与关闭: 方法表示组件能够发生的动作,或者组件的状态监测: 事件表 ...

  2. jQuery UI dialog 的使用

    今天用到了客户端的对话框,把 jQuery UI 中的对话框学习了一下. 准备 jQuery 环境 首先,我们创建一个按钮,点击这个按钮的时候,将会弹出一个对话框. 1 <input type= ...

  3. jQuery UI dialog 參数说明

    前段时间碰到个问题 jquery UI dialog弹出层 弹出多个层是 比方弹出两个层A和B  B层假设显示的数据表格太大,伸到了A层的外面,那伸到A层之外的部分就看不到了,由于B层是在A层上弹出的 ...

  4. Jquery - UI - Dialog(转)

    jQuery UI Dialog常用的参数有: 1.autoOpen:默认true,即dialog方法创建就显示对话框 2.buttons:默认无,用于设置显示的按钮,可以是JSON和Array形式: ...

  5. jQuery UI dialog 参数说明

    前段时间碰到个问题 jquery UI dialog弹出层 弹出多个层是 比如弹出两个层A和B  B层如果显示的数据表格太大,伸到了A层的外面,那伸到A层之外的部分就看不到了,因为B层是在A层上弹出的 ...

  6. 解决Select2控件不能在jQuery UI Dialog中不能搜索的bug

    本文使用博客园Markdown编辑器进行编辑 1.问题呈现 项目中使用了jQuery UI的Dialog控件,一般用来处理需要提示用户输入或操作的简单页面.逻辑是修改一个广告的图片和标题. 效果截图如 ...

  7. JQuery UI dialog 弹窗实例及参数说明

    按钮代码: <a id="suprise" style="margin-left: 0.5em;cursor:pointer;">点我会有惊喜< ...

  8. jQuery UI dialog

    初始化参数 对于 dialog 来说,首先需要进行初始化,在调用 dialog 函数的时候,如果没有传递参数,或者传递了一个对象,那么就表示在初始化一个对话框. 没有参数,表示按照默认的设置初始化对话 ...

  9. 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- ...

随机推荐

  1. 重新想象 Windows 8 Store Apps (52) - 绑定: 与 Element Model Indexer Style RelativeSource 绑定, 以及绑定中的数据转换

    [源码下载] 重新想象 Windows 8 Store Apps (52) - 绑定: 与 Element Model Indexer Style RelativeSource 绑定, 以及绑定中的数 ...

  2. FreeBSD的新一代包管理工具Pkg 1.3.0 发布

    Pkg 是 FreeBSD 下一代的打包管理工具,用来替代原来的 pkg_info/pkg_create/pkg_add 工具,可以本地打包,也提供远程打包,主要是为了方便远程二进制包升级. Pkg ...

  3. js限制input输入

    1.取消按钮按下时的虚线框,在input里添加属性值 hideFocus 或者 HideFocus=true <input type="submit" value=" ...

  4. PHP Warning: Module 'modulename' already loaded in Unknown on line 0

    问题 当在命令行运行PHP的CLI版本时,您可能会收到类似以下错误: [root@myserver /root]$ php -v PHP Warning: Module 'pcre' already ...

  5. 误报的java.sql.SQLException: Parameter number 21 is not an OUT parameter

    今天为了模拟一个mysql内存不释放问题,要测试一个存储过程,同时具有出参和入参,启动时报了上述错误. <select id="funcl_trd_secu_execution_que ...

  6. Mysql优化经验

    一.索引优化 范围匹配使用B-tree索引  等值匹配使用 HASH索引,hash所有唯一Memory引擎 2.索引三星系统, 1.相关记录放到一起 2.索引中的数据和查找中的排序顺序一直 3.索引的 ...

  7. JS 节流

    作为前端的小白,在做项目的过程中,一般只考虑到实现功能,并没有考虑到性能的问题. 比如说,下拉加载更多的这个功能和resize()是特别耗费性能的.此时就要想到节流了. 节流:就是然一个函数无法在短时 ...

  8. abap number range

    如有转载请注明出处:http://blog.csdn.net/donkey2004112103/archive/2009/04/13/4070996.aspx 1.sap numbe range在标准 ...

  9. Windows Azure 上传 VM

    One of the great features of Windows Azure is VHD mobility. Simply put it means you can upload and d ...

  10. 多线程之NSThread和NSObject

    #pragma mark - NSThread实现多线程 /* // 获取当前线程 NSLog(@"currentThread = %@", [NSThread currentTh ...