打印在asp.net中无效 [英] print is not working in asp.net

查看:71
本文介绍了打印在asp.net中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友一个小问题

i有一个代码写在下面打印特定控制数据(面板)

点击按钮

页面是重定向但如果我删除重定向代码打印代码工作正常打印代码不起作用

请解决方案



dear friend one little problem
i have a code written in below for the print the particular control data(panel)
on button click
the page is redirect but the print code is not work if i remove the redirect code the print code is working fine
please solutions

ClientScript.RegisterStartupScript(this.GetType(), "print", "<script>PrintPanel();</script>");
Response.Redirect("invoice.aspx");

推荐答案

根据您的代码,您发送一个JavaScript代码来调用一些客户端打印功能,而不是命令ASP.NET引擎重定向到其他页面。这意味着重定向之前的所有代码都是无用的,因为永远不会被执行...
According your code you send a JavaScript code to call some client print function, than order ASP.NET engine to redirect to some other page. It means that all your code before that Redirect is useless as never will be executed...


这与工作方式有关:整个页面被翻译为HTML,这是整个页面完成后发送到客户端(包含嵌入式javascript)。



Response.Redirect是一个中止功能:抛弃所有先前组装的数据并重新启动一个新的空白页面 - 所以你的启动脚本也被扔掉了。



你必须让客户打印,然后重定向完成。
This has to do with how things work: your entire page is "translated" to HTML which is sent up to the client (complete with embedded javascript) when the whole page is complete.

Response.Redirect is an "abort" function: it throws away all previously assembled data and starts again with a new, blank page - so your startup script is thrown away as well.

You have to let the client print, then redirect when he is finished.


你能做的是



what you can do is

function PrintPanel()
{
    // your code....
    //finally after you done with printing call redirect from javascript like below 
    window.location.href("invoice.aspx");
}


这篇关于打印在asp.net中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆