主窗体调用../QueryDialog.aspx子窗体, 并传参数window给子窗体
function ShowModalDialog()
{
//传递window对象给子窗体,以便子窗可以获取到父窗体上的控件
var returnValue = window.showModalDialog('../QueryDialog.aspx',window,'dialogWidth=500px;dialogHeight=200px;center=yes;resizable=yes;help=no;status=no;location=no');
if(returnValue == 1) //判断子窗口返回的参数值, 如果为1则刷新父窗口
{
alert(returnValue);
}
}
</script>
子窗体QueryDialog.aspx
1.返回参数值1给父窗体
Response.Write("<script language=javascript>window.returnValue='1';window.close();</script>");
2.得到父窗体参数var theOpener = window.dialogArguments;
执行父亲体内容btnQueryDialog按纽事件
var theOpener = window.dialogArguments;theOpener.document.getElementById('btnQueryDialog').click();
代码:
ClientScriptManager cs = Page.ClientScript;
cs.RegisterStartupScript(this.GetType(), "YesClose", "<script>var theOpener = window.dialogArguments;theOpener.document.getElementById('btnQueryDialog').click();window.close();</script>");