asp.netreporting-servicesreportviewer

SQL Reporting Services viewer for webpage - can you move the View Report button?


Using the viewer control for display of SQL Reporting Services reports on web page (Microsoft.ReportViewer.WebForms), can you move the View Report button? It defaults to the very right side of the report, which means you have to scroll all the way across before the button is visible. Not a problem for reports that fit the window width, but on very wide reports that is quickly an issue.


Solution

  • It's kind of a hack, but you can move it in JavaScript. Just see what HTML the ReportViewer generates, and write the appropriate JavaScript code to move the button. I used JavaScript to hide the button (because we wanted our own View Report button). Any JavaScript code that manipulates the generated ReportViewer's HTML must come after the ReportViewer control in the .aspx page. Here's my code for hiding the button, to give you an idea of what you'd do:

    function getRepViewBtn() {
      return document.getElementsByName("ReportViewer1$ctl00$ctl00")[0];
    }
    
    function hideViewReportButton() { // call this where needed
      var btn = getRepViewBtn();
      btn.style.display = 'none';
    }