4

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.

Joel Beckham
  • 18,254
  • 3
  • 35
  • 58
bonneyab
  • 85
  • 1
  • 2
  • 8

1 Answers1

3

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

Joel Beckham
  • 18,254
  • 3
  • 35
  • 58
  • Joel, this worked for me on IE after installing the Reporting Services Plugin. however, i couldn't make it work on Chrome, there is no prompt for installing the plugin. any suggestions ? – Muhammad Omar ElShourbagy Feb 20 '13 at 11:04
  • Joel, after visiting the msdn blog link, i read the comments and found that these JS APIs are only for active-x supported browsers. – Muhammad Omar ElShourbagy Feb 20 '13 at 11:09
  • 1
    As far as I remember, although it's been quite a while since I worked with this control, printing may not work in non-IE browsers. This link seems to indicate that: http://msdn.microsoft.com/en-us/library/ms251673.aspx. – Joel Beckham Feb 20 '13 at 19:40
  • Yes it seems like it. I'm using the '$find("ReportViewer1").exportReport()' and the user to print the exported files later. – Muhammad Omar ElShourbagy Feb 21 '13 at 09:27
  • Doco for Microsoft.Reporting.WebFormsClient.ReportViewer: https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/dd756405(v=vs.100) – Aralox Mar 03 '21 at 00:45