This is a migrated thread and some comments may be shown as answers.

Make Print button of web ReportViewer automatically print

4 Answers 537 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 2
James asked on 10 Nov 2008, 02:32 PM
I would like to make the print button in the web ReportViewer automatically print the report to the user's default printer, and also perform other actions based on the user printing the report.  Can you please provide a code example that would allow me to do this?

Thanks!

4 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 10 Nov 2008, 03:09 PM
Hello James,

We use the Adobe Plugin (if available) when printing and the user has the option to select the printer he would like to use. There is no way for us to know the default or all available printers a user has for security reasons. In order to perform other actions on click of the print button, you'll have to override the function like so:
<script type="text/javascript">
    ReportViewer.prototype.PrintReport = function()
    {
       //do your thing
      this.PrintAs("Default");
    }
</script>   

Hope this helps.


Regards,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
James
Top achievements
Rank 2
answered on 10 Nov 2008, 05:13 PM
Steve,
I must be missing something.  I put your code suggestion in my page and I keep getting a javascript error stating that "ReportViewer is undefined"

Here is my code:
    <script type="text/javascript">  
        ReportViewer.prototype.PrintReport = function() {  
            alert('Printing Report');  
            this.PrintAs("Default");  
        }  
    </script>  
 
0
Accepted
Steve
Telerik team
answered on 10 Nov 2008, 05:16 PM
Hi James,

Try adding the script block after the ReportViewer markup and see if that makes difference.

Best wishes,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
James
Top achievements
Rank 2
answered on 10 Nov 2008, 05:43 PM
Perfect Steve!!!!

Thanks for the help!
Tags
General Discussions
Asked by
James
Top achievements
Rank 2
Answers by
Steve
Telerik team
James
Top achievements
Rank 2
Share this question
or