如何打开打印对话框?显示错误为“未安装打印机".在服务器端单击报表中的“打印"按钮时

如何打开打印对话框?显示错误为“未安装打印机

问题描述:

在服务器端单击报告中的打印"按钮时显示错误为未安装打印机",但是当我在本地系统中运行时,页面没有问题...如何在服务器端解决该问题?

以下是我后面的代码中的代码:


受保护的void print_Click(对象发送者,EventArgs e)
{
试试
{
oReport1.Load(Server.MapPath(〜/Report/PaySalaryMonthWise.rpt"));


connection.DoCRLogin(oReport1);

CrystalReportViewer1.ReportSource = oReport1;
CrystalReportViewer1.DataBind();


oReport1.PrintToPrinter(1,false,0,0);



}
设计编号:

showing error as"no printer installed" on clicking print button in report at server side but when i run in my local system no problem the pages are getting printed...how to solve it in server side?

following is my code in my code behind:


protected void print_Click(object sender, EventArgs e)
{
try
{
oReport1.Load(Server.MapPath("~/Report/PaySalaryMonthWise.rpt"));


connection.DoCRLogin(oReport1);

CrystalReportViewer1.ReportSource = oReport1;
CrystalReportViewer1.DataBind();


oReport1.PrintToPrinter(1, false, 0, 0);



}
design code:

<asp:Button ID="print" runat="server"  Text ="Print"
            onclick="print_Click"
            style="top: 6px; left: 758px; position: absolute; height: 26px; width: 62px" />

首先:您必须了解该软件的哪一部分运行.
即使在本地开发计算机上进行测试,也要考虑两个不同的部分,即使它们在同一台物理计算机上也是如此.当您的网络应用托管在网络中的某个位置时,一部分(即服务器部分)位于托管服务器上.
当您执行asp.net代码时,这会在服务器上发生. IE.在互联网上的服务器上,而不是在本地计算机上!不,不在您的本地计算机上.
它在客户端计算机上用于打印报告的位置.因此,这是要在客户端上执行的操作,您可以在Web浏览器中看到应用程序的位置上进行打印. JavaScript在浏览器中运行.因此,请使用一些JavaScript来启动打印.
First of all: you have to understand where which part of the software runs.
Even when you test on your local development machine, there are two different parts to consider, even though they are on one physical machine. When your web application gets hosted somewhere in the web, one part - i.e. the server part - is on the hosting server.
When you execute asp.net code, that happens on the server. I.e. on the server in the internet, not on your local machine! No, not on your local machine.
It is on the client machine where to print the report. Consequently, that''s something to be executed there on the client where you see the application in a web browser where to do the printing. JavaScript runs in the browser. Consequently, use some JavaScript to initiate printing.


At this related question you have some links to look at for a solution