日期:2014-05-17  浏览次数:20391 次

.net弹出模式窗口,关闭后刷新父窗口
A.aspx 里有个repeater 每行后面有个查看详情的按钮  
 <a title="查看详细信息.." href="#" id='<%#Eval("T_UserID") %>' class="GetMes">
 <img src="Images/LookMes.gif" />
</a>
 点击按钮弹出一个模式窗口GetMoreMes.aspx 我用的showModalDialog

js代码
 
C# code

$(".GetMes").click(function() {
        if ($.trim($(this).attr("id")).length > 0) {
        window.showModalDialog("GetMoreMes.aspx?UID=" + $(this).attr("id"),"window","dialogwidth:710px;dialogheight:500px;center=yes;resizable:yes;help=no;status=no;");
                }
    })



GetMoreMes.aspx里一条记录的详细信息 点击保存后关闭子窗口并刷新父窗口 使父窗口数据得到更新

保存事件里调用
C# code
protected void BtnSaveWorkInfo_Click(object sender, EventArgs e)
    {
        。。。。。。。。。。。。。。。。
        。。。。。。。。。。。。。。。。。。。。
           StringBuilder scriptString = new StringBuilder();
            scriptString.Append("<script language = javascript>");
            scriptString.Append(" window.close(); ");
            scriptString.Append("</" + "script>");
            Response.Write(scriptString.ToString()); 


}


 如果用window.location.reload() 当A.aspx点击下一页页或者二次提交的时候 每次都会弹出 要再次显示该网页,Internet Explorer 需要重新发送你以前提交的信息
然后又改用location.href = location.href 这样不弹出了 但是关闭后总是回到初始页面了

很苦恼╮(╯▽╰)╭ 求解 求大侠

------解决方案--------------------
location.replace(location.href)
------解决方案--------------------
window.opener.location.reload(); //刷新父页面

window.close();//关闭当前页面