Click here to Skip to main content
10,500,000 members (79,327 online)
Click here to Skip to main content
Add your own
alternative version


22 bookmarked
Posted 7 Dec 2012

Print button and date picker in SSRS reports for non-IE browsers (Chrome, Firefox, etc.)

Rate this:
Please Sign up or sign in to vote.
This article will show you how to implement print functionality and the jQuery datepicker in non-IE browsers.


SQL Server Reporting Services ReportViewer control has some limitations in non-IE browsers such as Chrome, Firefox, etc. Some of these limitations are:

  • Print button is not visible.
  • Date picker is not displayed as a date picker control.

This article will help you achieve the solution for the above limitations and design some complex reports.  


I have searched so many articles on the internet but could not find a better complete solution with the source code and I thought to share my experience with some of you experiencing the same issues in your reporting. I hope this article will help you and save some of your development time. 

I am very thankful to those techies who shared their experience along with the source on the web and helped me achieve this piece of work.  

Using the code 

Implementation of Print functionality

With this article we will achieve a solution to display a custom print button shown in the following figure on the Report Viewer toolbar:

We will use the image control as a print button and the image control will be generated dynamically at runtime on the client side (please create your own GIF or JPEG image to show the image).

I know most of you will not agree with this approach but after a long research of more than a week I have come to a conclusion of implementing this functionality through AJAX calls to the server. This solution will create a temporary session PDF file and print the document at the client side and then delete the file on the server. Please follow these steps for the implementation (please make sure to have the user permissions on the server for creating/deleting the files).

Design of the ASPX page

  1. Place your ReportViewer control on the ASPX page:
  2. <rsweb:ReportViewer ID="rvREXReport" runat="server" Width="100%" Height="798px"
    Style="display: table !important; margin: 0px; overflow: auto !important;" 
    ShowBackButton="true" onreportrefresh="rrvREXReport_ReportRefresh">
  3. Place a server side iFrame below the ReportViewer:
  4. <iframe id="frmPrint" name="frmPrint" runat="server" style = "display:none"></iframe>
  5. Place the following div tag below the iframe declaration (this is to display the message while processing the AJAX request of printing):
  6. <div id="spinner" class="spinner" style="display:none;">
    <table align="center" valign="middle" style="height:100%;width:100%">
    <td><img id="img-spinner" src="../Images/ajax-loader.gif" alt="Printing"/></td>
    <td><span style="font-family:Verdana; font-weight:bold;font-size:10pt;width:86px;">Printing...</span></td>
  7. Place the ScriptManager:
  8. <asp:ScriptManager ID="ScriptManager1"  EnablePageMethods="true" 
        EnablePartialRendering="true" runat="server">
  9. CSS classes are used to highlight the print button when the mouse is hovered on the print button (these CSS classes are available in the attached ASPX page).

Implementation of the client side script (jQuery/JavaScript)

To show the print button we will create a client side method that will generate the print and close buttons at runtime (please make sure to have the JPG/GIF images ready before you start the implementation). This method will be called on the body load event as well as report refresh event (at server side). Here is the explanation of how this has been implemented:

  1. We will have to find where the refresh button is available in the HTML code of the ReportViewer control.
  2. Once the refresh button is found from the above step, we will have to find the parent of the refresh button to add the image control.

Following is the method that will be used to create the print and close buttons:

function showPrintButton() {    
var table = $("table[title='Refresh']");
var parentTable = $(table).parents('table');
 ......remaining code here......


Tip: Install the developer tool on your machine to understand the HTML code which is generated on placing the ReportViewer control in the ASPX page.

Here we have two different client side methods which will be called before printing the report and after printing the report:

  1.  Before the printing method is used to send an AJAX request to the server, create a PDF at server and assign to the iframe at server side.
  2. function ServerCallBeforePrint(btn) {
     var context = new Object(); 
     ......remaining code here......
  3. After printing method is used to send an AJAX request to the server, for deleting the PDF file which was created in the above step.
  4. function ServerCallAfterPrint(btn) {
        var context = new Object();
        ......remaining code here......  

    Tip: The attached ASPX page contains the full implementation of these methods.

Implementation of displaying jQuery datepicker


To implement this functionality, I have created a client side method which will be called on the document ready event. Following is the method used to display the jQuery datepicker:

function showDatePicker() {
   var parameterRow = $("#ParametersRowrvREXReport");
   ....remaining code here....

Please do not use exactly the same code as above because your parameter row ID might be different from the row ID in the above code. 

The following statements will explain how the parameter row ID is generated:

"ParametersRowrvREXReport" is the ID of the parameters row which can be identified from your HTML code generated by the ReportViewer control (as mentioned above, you would need to install the developer tool which is a freeware).

In the parameter row ID, the first part of the name is the common "ParametersRow (your ReportViewer name)" and the rest of the name is suffixed with your ReportViewer name. In the above example my ReportViewer name is "rvREXReport" which is why the name of the parameter row ID is generated as "ParametersRowrvREXReport".

And also, to find the date picker control (which is displayed as a texbox in Chrome/Firefox), I have used the label to find the table cell and from there I could identify the date control. Please note that we cannot rely on the name of the textbox as this will be generated at runtime and could be different. This is the reason I am using a label to find the date control on the report.

Tip: To use the above code, please make sure to use the date parameter in your report.

I have attached a sample project which contains the source with this article. Please note that this attachment will not contain the RDL file.

The attached project contains runnable files but will not contain support jQuery files (jquery-1.4.1.js, jquery-1.4.1.min.js, jquery-1.4.1-vsdoc.js) and the corresponding images. The attached project contains the proper structure to place all your files. I have tested this code properly in Google Chrome for my project and I hope this article will help you with all your needs to print the report in non-IE browsers and also display the jQuery datepicker control.  

Note: I have not included the SSRS report in the attached project. There are some configuration settings applied in the web.config file under the appSettings section. Please change those setting according to your needs. For your reference, I have attached a web.config file in the attached project.

What does the project contain?

  1. An ASPX page that implements the logic of displaying the print button and date picker control in the SSRS report viewer.
  2. ReportViewerCredentials.cs in the App_Code folder which is used to supply to the report the credentials to execute the report from the ASPX page.  
  3. A Web.config file which contains additional application settings in the appSettings section. 

Final Tips

  1. Keep the images under the "Images"  folder. Place your own "ajax-loader.gif" in this folder.
  2. Make sure all the default jQuery files (jquery-1.4.1.js, jquery-1.4.1.min.js, jquery-1.4.1-vsdoc.js) are under the scripts folder.
  3. Keep ReportViewerCredentials.cs under the App_Code folder of the project.
  4. Make sure to have permissions on the server to create and delete files.
  5. It is mandatory to have references to the following .NET libraries in the project:
    • Microsoft.Build.Framework
    • Microsoft.ReportViewer.Common
    • Microsoft.ReportViewer.WebForms
    • System.Management 

****If you like this article, please leave your comments/suggestions and rating.


If there are any further updates, they will be released in the next version.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Shashidhar Rao Nellutla
Software Developer (Senior)
United Kingdom United Kingdom
Completed Masters in Computer Applications.

You may also be interested in...

Comments and Discussions

QuestionThe resource cannot be found. Error Pin
phoohtoo18-Mar-16 0:47
memberphoohtoo18-Mar-16 0:47 
BugRe: The resource cannot be found. Error Pin
a.shokry6-Jun-16 1:29
membera.shokry6-Jun-16 1:29 
QuestionThanks Much! Pin
Member 1193302816-Nov-15 22:58
memberMember 1193302816-Nov-15 22:58 
QuestionFunction ShowPrintButton Pin
patelv6113-Aug-15 15:43
professionalpatelv6113-Aug-15 15:43 
Question2014 Pin
Member 983785723-Apr-15 22:37
memberMember 983785723-Apr-15 22:37 
QuestionCalendar Postion is not correct Pin
NeelamSingh198621-Jan-15 19:20
memberNeelamSingh198621-Jan-15 19:20 
AnswerRe: Calendar Postion is not correct Pin
Shashidhar Rao Nellutla18-Mar-15 8:05
memberShashidhar Rao Nellutla18-Mar-15 8:05 
GeneralGood Effort Pin
beshoynader16-Sep-14 0:12
memberbeshoynader16-Sep-14 0:12 
QuestionTesting results (half fail) Pin
DevJuan11-Nov-13 2:57
memberDevJuan11-Nov-13 2:57 
QuestionClient side html print function Pin
Malek Chtiwi8-Oct-13 13:57
memberMalek Chtiwi8-Oct-13 13:57 
Questionit is giving the 404 error Pin
Member 381950920-May-13 3:51
memberMember 381950920-May-13 3:51 
PraiseRe: it is giving the 404 error Pin
phoohtoo18-Mar-16 1:04
memberphoohtoo18-Mar-16 1:04 
QuestionRDL Pin
bradmarsh28-Feb-13 12:50
memberbradmarsh28-Feb-13 12:50 
GeneralThank You Pin
Patrick Harris10-Dec-12 7:54
memberPatrick Harris10-Dec-12 7:54 
QuestionThis article is for server side reporting but what about client side reporting? Pin
Demo Test8-Dec-12 22:40
memberDemo Test8-Dec-12 22:40 
AnswerRe: This article is for server side reporting but what about client side reporting? Pin
Shashidhar Rao Nellutla10-Dec-12 0:07
memberShashidhar Rao Nellutla10-Dec-12 0:07 
QuestionHow do I download the source code? Pin
Demo Test8-Dec-12 22:09
memberDemo Test8-Dec-12 22:09 
AnswerRe: How do I download the source code? Pin
Shashidhar Rao Nellutla10-Dec-12 0:01
memberShashidhar Rao Nellutla10-Dec-12 0:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171207.1 | Last Updated 10 Dec 2012
Article Copyright 2012 by Shashidhar Rao Nellutla
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid