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

最后都变了- 提交于 2019-12-04 04:25:52

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/3504747/how-to-call-print-from-asp-net-on-a-reportviewer-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!