• window.showModalDialog 弹出窗口,关闭子窗,刷新父窗,在 .CS 中的实现


    父窗口:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PopWindow.aspx.cs" Inherits="WebUI.PopWindow" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
       
            <script type="text/javascript" language="javascript">
    <!--
                
    function openChild() {
                    
    var k = window.showModalDialog("StreetTreeViewModule.aspx", window, "dialogWidth:335px;status:no;dialogHeight:300px");
                    
    if (k == 1)//判断是否刷新 
                    {
                        alert(
    '刷新');
                        window.location.reload();
                    }
                }
    //--> 
            </script>

    </head>
    <body>
        <form id="form1" runat="server">

          传递到父窗口的值:<input id="txt9" type="text" value="2500" name="txt9"/>

        <input name="cat" onclick="openChild()" type="button" value="弹出窗口"/>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        </form>
    </body>
    </html>

    弹出的子窗口:StreetTreeViewModule.aspx

     

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StreetTreeViewModule.aspx.cs" Inherits="WebUI.StreetTreeViewModule" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <base target="_self"/>
    <script type="text/javascript" language="javascript">
    <!--
        
    var k = window.dialogArguments;
        
    //获得父窗口传递来的值 
        
        
    //关闭窗口返回是否刷新的参数. 
        function winClose(isRefrash) {
            window.returnValue 
    = isRefrash;
            window.close();
        }
    //--> 
            </script>

    </head>
    <body>
        <form id="form1" runat="server">

         <table width="80%">
         <tr>
            <td align="left" height="100">

    <input id="Button2" onclick="winClose(1)" type="button" value="关闭刷新父窗口" name="CloseRefresh"/>
    <input id="Button3" onclick="winClose(0)" type="button" value="关闭不刷新父窗口" name="CloseNoFresh"/>
     <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
             </td>
         </tr>
        </table>
        </form>
    </body>
    </html>

    StreetTreeViewModule.aspx.CS  中

     protected void Button1_Click(object sender, EventArgs e)
            {
                this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), Guid.NewGuid().ToString(), "winClose(1);"true);

            }
  • 相关阅读:
    国内医保控费公司简单比较
    程序员生存定律--管理向左,技术向右
    程序员生存定律--细论软件这个行当的根本特征
    程序员生存定律--细论影响人生成绩的四个要素(2)
    程序员生存定律--细论影响人生成绩的四个要素(1)
    程序员生存定律--定律的概要
    程序员生存定律--交换是职场里一切的根本
    程序员生存定律--目录
    程序员生存定律--那个是你的人生出口
    程序员生存定律--程序人生的出口
  • 原文地址:https://www.cnblogs.com/tiger8000/p/2220016.html
Copyright © 2020-2023  润新知