ASP.NET:关闭子页面并刷新父页面

本文探讨了在使用ASP.NET进行网页开发时,如何在子页面操作完成后刷新父页面并关闭子页面对话框的问题。提供了两种实现方法,并讨论了它们的效果及潜在问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

模块一:

在子页面的选择按钮事件中加上:

1.this.Response.Write("<script>window.opener.location.href=window.opener.location.href;window.close();</script>");
this.Response.Write("<script>window.opener.location.replace(window.opener.document.referrer);window.close();</script>");   

 

2.   Response.Write("<script language:javascript>javascript:window.close();</script>");

      this.Response.Write("<script>window.opener.location.reload(); </script>");

用第一种方法时会出现不能正确返回到它的父页面,可能会转到父页面的浏览之前的页面

 

模块二:

父页面:

HyperLink Print = e.Item.Cells[e.Item.Cells.Count - 1].Controls[0] as HyperLink;
Print.Text = "操作";
string script = string.Format("javascript:window.showModalDialog(encodeURI('FixtureUpd.aspx?panelid=" + panelid + "&paneladdr=" + paneladdr + "&panelname=" + panelname + "'),window,'dialogWidth=300px;dialogHeight=100px;center=yes;scroll=no;status=no;')");
Print.Attributes.Add("href", script);

子页面:

Response.Write("<script language=javascript>");
Response.Write("alert('修改成功!');");
Response.Write("window.dialogArguments.location.href=window

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值