我需要帮助来通过单击弹出窗口中的提交按钮来重定向父页面
应该发生:
- 用户点击提交按钮,弹出窗口中的参数将通过 URL 传递
- 父页面将重定向到详细信息页面
- 弹出窗口已关闭
会发生什么:
- 用户点击提交按钮,弹出窗口中的参数将通过 URL 传递
- 已提交参赛作品
- 父级不重定向
- 弹出窗口被重定向
代码
ReturnValue.url = "TransDetailMain.aspx?AcctDate=" +AcctDate+ "&AcctCategoryCode=" +AcctCategoryCode+ "&DeptProfitCtr=" +DeptProfitCtr+ "&RefDocNum=" + RefDocNum + "&COMMAND=Edit&REFERRING_PAGE_KEY=MtMonthlyCatalystMain.aspx";//?AcctDate="+AcctDate;
//window.returnValue = ReturnValue;
window.location.href = ReturnValue.url;
// window.opener.location.href = ReturnValue.url;
//window.parent.location.href=ReturnValue.url;
// similar behavior as an HTTP redirect
// window.location.replace(ReturnValue.url);
问题:
- 用于在 Windows 2003 服务器中工作的代码
- 迁移到 2008 年,它不再起作用
最佳答案
我假设你正在使用 JavaScript,所以我在这里写
在这里查看我的答案 How to close current Browser window and redirect to a previously opened window for the same browser
String x = "<script type='text/javascript'>window.opener.location.href='**Your new url of new page after completing test**';self.close();</script>";
ScriptManager.RegisterClientScriptBlock(this.Page,this.Page.GetType(), "script", x,false);
它说明 self.close() 当前将被关闭,新的 url 将被打开 所以你的新代码将如下所示
现在怎么办
String x = "<script type='text/javascript'>window.opener.location.href='**TransDetailMain.aspx?AcctDate=" +AcctDate+ "&AcctCategoryCode=" +AcctCategoryCode+ "&DeptProfitCtr=" +DeptProfitCtr+ "&RefDocNum=" + RefDocNum + "&COMMAND=Edit&REFERRING_PAGE_KEY=MtMonthlyCatalystMain.aspx**';self.close();</script>";
ScriptManager.RegisterClientScriptBlock(this.Page,this.Page.GetType(), "script", x,false);
将其放入弹出的提交点击中 所以会发生的情况是父窗口将被重定向并且当前窗口将被关闭 注意:此代码未经测试 我希望这会对您有所帮助...:)
关于javascript - 重定向父级 - 关闭弹出窗口 - ASP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19393757/