如何打印页面然后使用Asp.net中的Javascript重定向 [英] How do I page print then redirect with Javascript in Asp.net
本文介绍了如何打印页面然后使用Asp.net中的Javascript重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好..
我想首先打印页面,然后重定向。我使用下面的代码,但此代码仅重定向没有页面打印。我该如何解决这个问题?
ScriptManager.RegisterClientScriptBlock( this , typeof (页面), 脚本, window.print();, true 跨度>);
ScriptManager.RegisterClientScriptBlock( this , typeof (页面), 脚本,window.location.href = ' Default.aspx'; ,true);
感谢帮助。
解决方案
你可以做通过javascript打印和重定向。这是一个应该工作的例子:
function doPrint(){
window.print();
document.location.href = Default.aspx;
}
将其链接到按钮:
< asp:按钮 id = btnPrint runat = server text = 打印 xmlns:asp = #unknown >
OnClientClick = doPrint(); return false;/> < / asp:button > 跨度>
Hi guys..
I want to first my page print then redirect. I use below code but this code only redirect without page print. How can I solve this problem ?
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "Script", "window.print();", true);
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "Script",window.location.href='Default.aspx';", true);
Thanks for helps.
解决方案
You can do the printing and redirect all via javascript. Here is an example that should work:
function doPrint() { window.print(); document.location.href = "Default.aspx"; }
Link it to a Button:
<asp:button id="btnPrint" runat="server" text="Print" xmlns:asp="#unknown"> OnClientClick="doPrint(); return false;" /></asp:button>
这篇关于如何打印页面然后使用Asp.net中的Javascript重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文