asp.net中无限制弹出模态窗口

特点:

1.       可以在模态窗口上再弹出模态窗口,不限制次数

2.       弹出窗口的支持拖放,及调整大小

3.       弹出窗口关闭后可以动态控制是否刷新父窗口

总共需要3个页面来做演示

1. 页面ModalDemo.aspx

前台代码:

<head runat="server">

    <title>无标题页</title>

    <base target="_self"  />

    <script type="text/javascript">

function OpenDialogWithReturn(url,width,height,formID,action)

{

     var retValue = window.showModalDialog( url ,null,"dialogWidth:" + width + "px;dialogHeight:" + height +  "px;help:no;unadorned:yes;resizable:yes;status:no;scrollbars:yes");

     if (retValue !=  null && retValue != undefined && retValue == "SubmitForm")

     {

      if(action !=  null  && action != undefined && action.Length > 0)

       {

         formID.Action=action;

      }

       formID.submit();

     }

}

    </script>

</head>

<body>

    <form id="form1"  runat="server">

    <div>

        <a href="#"  onclick="OpenDialogWithReturn('ModalPage1.aspx',520,410,form1,'ModalDemo.aspx');">通过页面脚本来弹出模态窗口</a><br />

        <br />

        <br /><asp:Button ID="btnDetail"  runat="server" 

                onclick="btnDetail_Click" Text="通过动态注册弹出窗口" />

&nbsp;<br />

        <div>

            <%=DateTime.Now %>

        </div>

    </div>

    </form>

</body>

后台代码:

protected  void btnDetail_Click(object sender,  EventArgs e)

        {

            this.ClientScript.RegisterStartupScript(this.GetType(), "", "OpenDialogWithReturn('ModalPage1.aspx',520,410,form1,'ModalDemo.aspx');", true);

        }

2.第二个页面ModalPage1.aspx

前台代码:

<head runat="server">

    <title>第一个模态窗口</title>

    <base target="_self"  />

    <script type="text/javascript">

function OpenDialogWithReturn(url,width,height,formID,action)

{

     var retValue = window.showModalDialog( url ,null,"dialogWidth:" + width + "px;dialogHeight:" + height +  "px;help:no;unadorned:yes;resizable:yes;status:no;scrollbars:yes");

     if (retValue !=  null && retValue != undefined && retValue == "SubmitForm")

     {

      if(action !=  null  && action != undefined && action.Length > 0)

       {

         formID.Action=action;

      }

       formID.submit();

     }

}

    </script>

</head>

<body onunload="window.returnValue='SubmitForm';">

    <form id="form1"  runat="server">

    <div>

        <a href="#"  onclick="OpenDialogWithReturn('ModalPage2.aspx',500,400,form1,'ModalPage1.aspx');">

            通过页面脚本来弹出模态窗口</a>

        <br />

        <br />

        <asp:Button ID="Button1"  runat="server" Text="通过动态注册脚本来弹出模态窗口" 

            OnClick="Button1_Click" />

        <br />

        <br />

        <br />

        <asp:Button ID="btnOK"  runat="server" OnClick="btnOK_Click" Text="确定" />

        <br />

        <div>

            <%=DateTime.Now %></div>

    </div>

    <asp:Button ID="Button2"  runat="server" Text="添加" />

    </form>

</body>

后台代码:

//弹出新的模态窗口

        protected  void Button1_Click(object sender,  EventArgs e)

        {

            this.ClientScript.RegisterStartupScript(this.GetType(), "", "OpenDialogWithReturn('ModalPage2.aspx',500,400,form1,'ModalPage1.aspx');", true);

        }

        //关闭当前窗口,并刷新父页面

        protected  void btnOK_Click(object sender,  EventArgs e)

        {

            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "window.returnValue='SubmitForm';window.close();", true);

        }

3. 第三个页面ModalPage2.aspx

前台代码:

<head runat="server">

    <title>第二个模态窗口</title>

    <base target="_self"  />

</head>

<body onunload="window.returnValue='SubmitForm';">

    <form id="form1"  runat="server">

    <div>

        <asp:Button ID="Button1"  runat="server" Text="ok" OnClick="Button1_Click" />

    </div>

    <div>

        <asp:Button ID="Button2"  runat="server" Text="添加" />

    </div>

    <br />

    <div>

        <%=DateTime.Now %></div>

    </form>

</body>

后台代码:

//关闭当前窗口,并刷新父窗口

        protected  void Button1_Click(object sender,  EventArgs e)

        {

            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "window.returnValue='SubmitForm';window.close();", true);

        }

asp.net弹出多个模态窗口的更多相关文章

  1. asp .NET弹出窗口 汇总(精华,麒麟创想)

    asp .NET弹出窗口 汇总(精华,麒麟创想) 注://关闭,父窗口弹出对话框,子窗口直接关闭 this.Response.Write("<script language=javas ...

  2. Asp.net弹出层并且有遮罩层

    长久以来,asp.net弹出层并且有遮罩层问题都是一个难以解决的问题,鉴于此,我决定写个弹出层发布出来,供大家使用... 这里的doing层是遮罩层,divLogin层是登陆层 若有其他问题请留言或邮 ...

  3. asp.net 弹出式日历控件 选择日期 Calendar控件

    原文地址:asp.net 弹出式日历控件 选择日期 Calendar控件 作者:逸苡 html代码: <%@ Page Language="C#" CodeFile=&quo ...

  4. ASP.NET弹出提示点击确定之后再跳转页面的方法

    //ASP.NET弹出提示点击确定之后再跳转页面的方法 //弹出了提示并且通过location.href转到了DeskTop.aspx页面 Response.Write("<scrip ...

  5. 点击文字弹出一个DIV层窗口代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...

  6. [转]C# 安装时弹出设置服务登录窗口

    本文转自:http://blog.csdn.net/prince_jun/article/details/38435887 安装服务时系统不要弹出设置服务登录窗口:在程序中将serviceProces ...

  7. C# Winform在win10里弹出无焦点的窗口

    原文:C# Winform在win10里弹出无焦点的窗口 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/wangmy1988/article/det ...

  8. SetWinEventHook 事件钩子(有些windows事件并没有消息对应,譬如弹出菜单,切换窗口,获得焦点,滚动条滚动等)good

    相信消息钩子大家听的比较多,消息钩子能够在应用程序处理系统消息之前将其截获,提前处理并可以决定是否继续将消息往下传送,有些windows事件并没有消息对应,譬如弹出菜单,切换窗口,获得焦点,滚动条滚动 ...

  9. jquery3和layui冲突导,致使用layui.layer.full弹出全屏iframe窗口时高度152px问题

    项目中使用的jquery版本是jquery-3.2.1,在使用layui弹出全屏iframe窗口时,iframe窗口顶部总是出现一个152px高的滚动窗口无法实现真正全屏,代码如下: <!DOC ...

随机推荐

  1. delphi 文件搜索,遍历所有子目录

    function ListFiles(path: string): TStringList; var SearchRec: TSearchRec; found: integer; begin resu ...

  2. linux中fork创建进程讲解(转)

    大家知道Linux中创建子进程的一个很好的方法是函数调用fork,但是很多初学者对fork的理解上可能有点困难.我们举个例子来看看fork的用法吧.         大家用fork的时候记住fork是 ...

  3. IIS的Connection由改为close改为Keep-Alive

    参考地址:http://jingyan.baidu.com/article/60ccbceb0c884864cab19784.html 官方:http://technet.microsoft.com/ ...

  4. centos6.4 ceph安装部署之ceph object storage

    preface: ceph-deploy does not provide a rapid installation for Ceph Object Storage install Configura ...

  5. linux 和unix 的区别

    Linux与Unix的区别  某些PC机的Unix和Linux在实现方面相类似.几乎所有的商业Unix版本都基本支持同样的软件.程序设计环境和网络特性.然而,Linux和Unix的商业版本依然存在许多 ...

  6. AndroidUI 引导页面的使用

    一个应用程序都少不了欢迎页面和引导页面,本文主要讲如何制作一个引页面: 首页所有的目录结构: 新建Welcome引导页面和Activity: <RelativeLayout xmlns:andr ...

  7. AndroidUI 视图动画-旋转动画效果 (RotateAnimation)

    RotateAnimation,能实现Android的视图的旋转效果,废话不多说直接上代码. 新建一个Android 项目,在activity_main.xml中添加一个按钮,然后使用Relative ...

  8. 全国计算机等级考试二级教程-C语言程序设计_第15章_位运算

    位运算,不适用于实数,仅仅适用于整数.字符. C语言的位运算只能操作整数.字符,实数是指数方式表示的,不适用于位运算. #define _CRT_SECURE_NO_WARNINGS #include ...

  9. nginx安装编译详解

    ./configure --prefix --with解释 http://zhidao.baidu.com/link?url=pksp8xh2OVbRS8_wUMv4ILpb7P6VVIU-NQVp6 ...

  10. EC读书笔记系列之16:条款35、36、37、38、39、40

    条款35 考虑virtual函数以外的其他选择 记住: ★virtual函数的替代方案包括NVI手法及Strategy模式的多种形式.NVI手法自身是一个特殊形式的Template Method模式 ...