jellis613
asked on
Select a Printer in ASP.net page
I am trying to print a ReportDocument (Crystal Reports) using the ReportDocument.PrintToPrin ter() function. The first parameter that this function needs is the printer name to which the document should be printed. I am trying to use the System.Windows.Forms.Print Dialog class to open up a print dialog and use it to set the printer to which the document should be printed. Here is my code:
ReportDocument rd = LoadReport(litFileName.Tex t); // Function to generate report document
System.Windows.Forms.Print Dialog pDlg = new System.Windows.Forms.Print Dialog();
pDlg.AllowSomePages = true;
pDlg.ShowHelp = true;
if (pDlg.ShowDialog() == System.Windows.Forms.Dialo gResult.OK ) {
rd.PrintOptions.PrinterNam e = pDlg.PrinterSettings.Print erName;
int numOfCopies = pDlg.PrinterSettings.Copie s;
rd.PrintToPrinter(numOfCop ies,true,1 ,1);
}
When I run this code, I get the following error (thrown on the ShowDialog() method call): "It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application."
After doing some web-searching, it seems that you cannot open a Windows.Forms dialog/message box through an ASP.net application.
Is this true? If so, how can I find out the name of the user's default printer in order that I can send this to ReportDocument.PrintToPrin ter()??
ReportDocument rd = LoadReport(litFileName.Tex
System.Windows.Forms.Print
pDlg.AllowSomePages = true;
pDlg.ShowHelp = true;
if (pDlg.ShowDialog() == System.Windows.Forms.Dialo
rd.PrintOptions.PrinterNam
int numOfCopies = pDlg.PrinterSettings.Copie
rd.PrintToPrinter(numOfCop
}
When I run this code, I get the following error (thrown on the ShowDialog() method call): "It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application."
After doing some web-searching, it seems that you cannot open a Windows.Forms dialog/message box through an ASP.net application.
Is this true? If so, how can I find out the name of the user's default printer in order that I can send this to ReportDocument.PrintToPrin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER