打开自适应子窗体,关闭子窗体刷新父窗体

-

    很少使用window.open()方法。做了一个打开自适应子窗体,关闭子窗体刷新父窗体的DEMO。

    父窗体ParentWin.aspx

Code

     ParentWin.aspx.cs  

     protected void Page_Load(object sender, EventArgs e)
    {
        txtBox.Text = System.DateTime.Now.ToString();//验证页面刷新
    }

Code

     ChildWin.aspx.cs

     protected void btnCloseServer_onclick(object sender, EventArgs e)
    {
        Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "error", "<script language='javascript'>alert('子窗口!');self_ReplaceParent(1);window.close();</script>");

    }

   可以再借助AJAX UpdatePanel,刷新父窗体的局部页面,给用户带来更好的体验。

 <打开模式窗体:window.showModalDialog('http://www.17vs.com',null,'toolbar=no,resizable=no,scrollbars=yes,location=no, status=no');">

如果打开的是模式子窗体,要在子窗体的head标签里加上<base   target="_self">,否则在处理服务器端控件的时候,会弹出新窗体!

原文地址:https://www.cnblogs.com/xiaorong/p/1421534.html