Hello
I had created a web based asp.net project on visual studio 2010 ultimate.
I have crystal reports in my project but I have not used reportviewer to view it.
On clicking on print button, the print dialog box should appear and reports will be printed.
The code that i had written worked fine in my ASP.NET application inside visual studio 2010.
but as soon as i deployed it and uploaded it in server, it showed a error that
Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
I searched the error in google and came to know that windows dialog box wont work in server.
I am pasting my print code here, can anyone please help me what code to be replaced so that on clicking on print button, print dialog box appears on the server and my reports gets printed.
Kindly please help as its a need.
I always prefer codeproject.com. Here experts are very helpful. I dont have much idea about javascript code or other.
protected void btnPrint_Click(object sender, EventArgs e)
{
ReportDocument rDoc = new ReportDocument();
PrintDialog dialog1 = new PrintDialog();
rDoc.Load(Server.MapPath("SoldCrystalReport.rpt"));
rDoc.SetParameterValue("@Category", ddlCategory.SelectedValue);
rDoc.SetDatabaseLogon("sa", "gariahat");
dialog1.AllowSomePages = true;
dialog1.AllowPrintToFile = false;
if (dialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
int copies = dialog1.PrinterSettings.Copies;
int fromPage = dialog1.PrinterSettings.FromPage;
int toPage = dialog1.PrinterSettings.ToPage;
bool collate = dialog1.PrinterSettings.Collate;
rDoc.PrintOptions.PrinterName = dialog1.PrinterSettings.PrinterName;
rDoc.PrintToPrinter(copies, collate, fromPage, toPage);
}
rDoc.Dispose();
dialog1.Dispose();
Thanks in advance
Please kindly help