关闭弹出模态窗口以后刷新父窗口

Method One://C# Code

openFrm(this, "WM_T_DIC_Meeting_EDIT.aspx", "",300,250, "no");

public static void openFrm(Page ImportPage, String OpenFormName, String Parmer, Int32 Width, Int32 Heigh,String scroll)
        {
           
            string str = OpenFormName + "?" + Parmer;
            string script = @"var date = new Date();var modalDial =window.showModalDialog('" + str + @"&Date='+date.getMilliseconds                          (),window.self,'dialogWidth:" + Width + "px;dialogHeight:" + Heigh + "px;scroll:" + scroll + ";status:no;help:no;');

          window.location = window.location;";
            if (!ImportPage.ClientScript.IsStartupScriptRegistered(ImportPage.GetType(), script))
            {
                ImportPage.Page.ClientScript.RegisterStartupScript(ImportPage.GetType(), "", script, true);
            }
        }

Method Two://C# + JS Code

//选择文号信息
function OpenDialog_ChoseFileCodeInfo(url) {
    var returnvalue = new Array(3);
    returnvalue = window.showModalDialog(url, '选择文号信息', 'DialogWidth:500px;DialogHeight:300px;help:no;status:no');

    if (returnvalue != null) {
        document.getElementById('tbxBudgetName').value = returnvalue[1];
        document.getElementById('tbxBudgetMoney').value = returnvalue[3];
        document.getElementById('tbxBudgetTypeName').value = returnvalue[2];
        document.getElementById('tbxFileCode').value = returnvalue[4];
        document.getElementById('tbxFileCodeName').value = returnvalue[5];
        document.getElementById('hdfldFileCodeID').value = returnvalue[0];
        document.getElementById('tbxReportBillName').value = returnvalue[1]; //默认申报单名称为预算名称
        window.location = window.location;
        return true;
    }
    else {
        return true;
    }
}

//后台代码

       int intRow = Convert.ToInt32(e.CommandArgument);
                    string BudgetID = GridView_TSoft.DataKeys[intRow]["PK_PBatchBudgetID"].ToString();
                    string BudgetName = GridView_TSoft.DataKeys[intRow]["F_BudgetName"].ToString();
                    string Money = GridView_TSoft.DataKeys[intRow]["F_Money"].ToString();
                    string FileCode = GridView_TSoft.DataKeys[intRow]["F_FileCode"].ToString();
                    string BudgetType = GridView_TSoft.DataKeys[intRow]["F_BudgetTypeName"].ToString();
                    string FileCodeName = GridView_TSoft.DataKeys[intRow]["F_FileCodeName"].ToString();
                    string function;
                    function = (@"<script language='javascript'>
                     var returnvalue = new Array(3);
                     returnvalue[0] = '") + BudgetID + (@"';
                                                returnvalue[1] = '") + BudgetName + (@"';
                                                returnvalue[2] = '") + BudgetType + (@"';
                                                returnvalue[3] = '") + Money + (@"';
                                                returnvalue[4] = '") + FileCode + (@"';
                                                returnvalue[5] = '") + FileCodeName + (@"';
                     window.returnValue = returnvalue;
                     window.close();
                    </script>");
                    this.RegisterStartupScript("Page", function);

//前台 html 代码

<asp:GridView ID="GridView_TSoft" runat="server" Width="100%" AutoGenerateColumns="False"
                    AllowSorting="True"      

       DataKeyNames="PK_PBatchBudgetID,F_BudgetName,F_BudgetTypeName,F_FileCodeName,F_Money,F_FileCode"
                    OnLoad="Page_Load" AllowPaging="True"
                    OnRowCommand="GridView_TSoft_RowCommand"
                    onpageindexchanging="GridView_TSoft_PageIndexChanging">
                    <HeaderStyle CssClass="gvwTitle"></HeaderStyle>
                    <Columns>
                        <asp:BoundField DataField="F_BudgetName" HeaderText="年预算名称"
                            >
                            <ItemStyle HorizontalAlign="Center" CssClass="gvwRow"/>
                        </asp:BoundField>
                        <asp:BoundField DataField="F_Money" HeaderText="年预算额(万元)"
                             >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="F_FileCode" HeaderText="文号"
                             >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:ButtonField Text="选择" CommandName="Select">
                            <ItemStyle Width="50" HorizontalAlign="center" Wrap="false" />
                        </asp:ButtonField>
                    </Columns>
                </asp:GridView>

原文地址:https://www.cnblogs.com/JackieYang/p/1678028.html