vb.net ASP.NET 从 iFrame 中刷新父页面
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14608380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ASP.NET Refresh Parent Page from within iFrame
提问by MF Luder
Working in ASP.NET. I have a main page with an iFrame inside it. The main page lists payor names, the iFrame lists the details of the selected payor. On the iFrame page I have a link button that launches a modal dialog window and allows the user to copy an existing payor to a new payor. When I close the modal dialog window I want to refresh the main page to include the newly added payor.
在 ASP.NET 中工作。我有一个主页,里面有一个 iFrame。主页列出付款人姓名,iFrame 列出所选付款人的详细信息。在 iFrame 页面上,我有一个链接按钮,可以启动一个模式对话框窗口,并允许用户将现有付款人复制到新付款人。当我关闭模式对话框窗口时,我想刷新主页以包含新添加的付款人。
I read this: asp.net Refresh base page from iframebut it is not working for me.
我读到这个:asp.net Refresh base page from iframe但它对我不起作用。
My iFrame aspx page has the following:
我的 iFrame aspx 页面具有以下内容:
function RefreshParent() {
window.parent.location.href = window.parent.location.href;
}
The iFrame code-behind page has the following in the Page_Load:
iFrame 代码隐藏页面在 Page_Load 中有以下内容:
ClientScript.RegisterStartupScript(Me.GetType, "RefreshParent", "<script type=text/javascript>RefreshParent();</script>", True)
When I close the modal dialog window the parent page is NOT refreshed, but this appears in the bottom left of the screen, under the iFrame page:
当我关闭模态对话框窗口时,父页面不会刷新,但这会出现在屏幕左下角的 iFrame 页面下:
//]]>
//]]>
The RegisterStartupScript only happens under certain conditions, but I've stepped through it in debug and confirmed those conditions are met, and that line of code is executing.
RegisterStartupScript 仅在某些条件下发生,但我已经在调试中逐步完成并确认满足这些条件,并且该行代码正在执行。
Any help would be much appreciated.
任何帮助将非常感激。
采纳答案by MF Luder
Figured it out. I had to change the code-behind page to this:
弄清楚了。我不得不将代码隐藏页面更改为:
ClientScript.RegisterStartupScript(Me.GetType, "RefreshParent", "<script type=text/javascript>RefreshParent();</script>", False)
Now the screen refreshes correctly and the //]]> does not appear.
现在屏幕正确刷新并且 //]]> 不会出现。

