C#弹出子窗体及自动关闭子窗体并刷新父窗体

 、打开子窗体前台脚本代码

<script type="text/javascript">
function showWindow() {
var iTop = (window.screen.availHeight - 30 - 400) / 2;
//获得窗口的水平位置
var iLeft = (window.screen.availWidth - 10 - 800) / 2;
//window.showModalDialog("UsedDetail.aspx?ID=" + maCode, "使用明细", "dialogHeight=400px,dialogWidth=800,center=yes,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no, status=no");
window.open("UserJiluZhuanyiDetial.aspx", "使用明细", "dialogHeight=400px,dialogWidth=800,left=" + iLeft + ",top=" + iTop + ",center=yes,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no, status=no");
}
</script>

 

2、父窗体按钮单击事件打开子窗体

<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click"/>

 

protected void Button1_Click(object sender, EventArgs e)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "closeWindow", "showWindow()", true);
}

 

3、子窗体按钮单击后关闭子窗体并刷新父窗体

protected void Button1_Click(object sender, EventArgs e)
{
this.Response.Write("<script>window.opener.location.href=window.opener.location.href;window.close();</script>");
}

转自:http://hi.baidu.com/liuzhenhe19881/blog/item/760f3d32d8e085b55edf0ea8.html

你可能感兴趣的:(JavaScript,function,休闲,前台,center)