页面之间的关系如下:A页面 ---window.showModalDialog 弹出--- B页面(由C页面与D页面组成)现在A页面中有"BtnRefresh"按钮,D页面中有"BtnOk"按钮.想实现在单击BtnOK后,关闭B页面同时执行A页面中的BtnRefresh_Click事件实现代码如下:
D页面中protected void BtnOk_Click(object sender, EventArgs e)
{
   ClientScriptManager cs = Page.ClientScript;
   cs.RegisterStartupScript(this.GetType[code=C#](), "YesColse", "<script>window.parent.opener.document.getElementById('BtnRefresh').click();window.parent.close();</script>");
}
[/code]运行测试后,弹出错误提示:window.parent.opener.document为空或找不到物件.求高手指点迷津~

解决方案 »

  1.   


    protected void BtnOk_Click(object sender, EventArgs e)
    {
       ClientScriptManager cs = Page.ClientScript;
       cs.RegisterStartupScript(this.GetType(), "YesColse", " <script>window.parent.opener.document.getElementById('BtnRefresh').click();window.parent.close(); </script>"); 
      

  2.   

    window.showModalDialog 打开的子窗口,不支持 window.opener 属性获取父窗口,需要显示作为参数传入// a.aspx
    window.showModalDialog("b.aspx", window);
    // b.aspx
    var theOpener = window.dialogArguments;
    theOpener.close();// 对于内嵌 c.aspx ->
    var outerOpener = window.top.dialogArguments;
    outerOpener.close();
      

  3.   

    outerOpener.document.getElementById('BtnRefresh').click();
      

  4.   

    window.showModalDialog 打开的子窗口,不支持 window.opener 属性 获取父窗口,需要显示作为参数传入 
    ==
    这两句非常关键
      

  5.   

    感谢 Jinglecat(晓风残月) ,amandag (高歌)