打开一页并引用当前页 [英] Opening one page and refershing the current page
问题描述
在我的应用程序中,用户将填写特定页面,然后,他会将数据安全保存到数据库中.将数据保存到数据库后,他将需要打印数据并刷新页面以接受新输入.我已完成以下操作:
ClientScript.RegisterStartupScript(this.GetType(),"onclick",<脚本语言= javascript> window.open(``PrintHelperDocument.aspx'',``PrintMe'',''height = 500px,width = 1000px, scrollbars = 1'');</script>);
Response.Redirect("BondData.aspx");
如果执行此操作,则不会打开打印页面,只有当前页面会刷新.如何打开新页面并同时刷新当前页面?
In my application the user will fill certain page and after that, he will safe the data to the database. After saving the data to the database, he will need to print the data and refresh the page to accept new input. I have done the following:
ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open(''PrintHelperDocument.aspx'',''PrintMe'',''height=500px,width=1000px,scrollbars=1'');</script>");
Response.Redirect("BondData.aspx");
If I did this, the print page is not opened and only the current page get refreshed. how can I open the new page and at the same time refresh the current one?
推荐答案
您将要使用JavaScript来完成所有操作.记住发生了什么.执行所有C#代码,然后将html发送到客户端.因此,由于您以Response.Redirect结尾,因此重定向到一个新页面,这是发送到客户端的唯一页面,因此,从不发送用于打开窗口的JavaScript.
在JS中具有类似于以下功能:
You''ll want to do it all in JavaScript. Remember what is happening. All of the C# code executes and then sends the html to the client. So, since you end with a Response.Redirect to a new page, that is the only page sent to the client so your JavaScript to open the window is never sent.
Have a function in JS similar to:
function Something()
{
window.open('PrintHelperDocument.aspx','PrintMe','height=500px,width=1000px,scrollbars=1');
window.location = "BondData.aspx";
}
http://codepen.io/xszaboj/pen/EPKjvb [ ^ ]
希望对您有所帮助
http://codepen.io/xszaboj/pen/EPKjvb[^]
Hope it will help
这篇关于打开一页并引用当前页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!