如何从子网页表单刷新asp.net主网页表单

时间:2015-06-03 13:52:09

标签: asp.net

我的asp.net项目中有两个Web表单,在Web表单编号1中我有一个按钮,我编写此代码以打开Web表单编号2:

Response.Write("<script> var myWindow = window.open('DatePicker.aspx', '', 'width=400, height=500');</script>");


当打开Web表单编号2时,我希望在关闭Web表单编号2时,Web表单编号1刷新,因此我将此代码写在Web表单编号2上:

<script type="text/javascript">
function RefreshParent() {
            if (window.opener != null && !window.opener.closed) {
                window.opener.location.reload();
                window.close(); // ADDED LINE
            }
        }
        window.onbeforeunload = RefreshParent;
    </script>


但网页表单1号没有重载,会发生什么?

1 个答案:

答案 0 :(得分:0)

试试这个

 function RefreshParent() {
        if (window.opener != null && !window.opener.closed) {
           window.location= "webformnumber1.aspx"; 
        }
    }

如果(window.opener!= null&amp;&amp;!window.opener.closed)条件正在执行,请确保您的代码在内部