bonneyab
bonneyab

Reputation: 85

How to call print from asp.net on a reportviewer control?

I'm using ssrs with an asp.net reportviewer control to display server reports. We want to do away with the toolbar because it doesn't fit with our look and feel but we want to maintain some of the functionality, the one bit I'm struggling with is the print. Is there any way to bring up the same print dialog as the print button on that toolbar from the asp.net page?

http://msdn.microsoft.com/en-us/library/ms252091(v=VS.80).aspx

Is the closest that I’ve found, however I’m not using local reports (so it would make sense if there was a built in function around somewhere), and it skips the printer dialog portion which is unacceptable. I don’t believe that I can actually call the winforms printdialog on an asp.net page, but it’s not something I’ve tried. Any help would be much appreciated.

Upvotes: 4

Views: 16293

Answers (1)

Joel Beckham
Joel Beckham

Reputation: 18648

Here is a script to bring up the print dialog:

<script language="javascript"> 
         function PrintReport() { 
             var viewerReference = $find("ReportViewer1");

             var stillonLoadState = clientViewer.get_isLoading();

             if (!stillonLoadState ) { 
                 var reportArea = viewerReference .get_reportAreaContentType(); 
                 if (reportArea == Microsoft.Reporting.WebFormsClient.ReportAreaContent.ReportPage) { 
                     $find("ReportViewer1").invokePrintDialog(); 
                 } 
             } 
         } 
     </script>

To invoke, just call PrintReport()

Detailed explanation here: http://blogs.msdn.com/b/selvar/archive/2011/04/09/invoking-the-print-dialog-for-report-viewer-2010-control-using-the-javascript-api.aspx

Upvotes: 3

Related Questions