ReportViewer height issue. Hiding scrollbars

reporting-services, reportviewer

Solution

You can set the height using javascript and keep Async=true. I use this now on the 2008 version. Here is the code I use:

<script language="JavaScript" type="text/JavaScript">
    function doResize() {
        var viewer = document.getElementById("<%=ReportViewer1.ClientID %>");
        var htmlheight = document.documentElement.clientHeight; 
        viewer.style.height = (htmlheight - 150) + "px";
    }

    window.onresize=function resize()
    { 
        doResize();
    }
</script>

<rsweb:ReportViewer ID="ReportViewer1" BackColor="#f2f2f2" 
    InternalBorderStyle="Solid" InternalBorderColor="Gray" ProcessingMode="Remote" 
    AsyncRendering="true" Width="100%" runat="server" 
    meta:resourcekey="ReportViewer1Resource1">
    <ServerReport  />        
</rsweb:ReportViewer>

<script language="JavaScript" type="text/JavaScript">
    doResize();
</script>

This doesn't work on VS2010 ReportViewer, however. I'm trying to figure out a solution for that.

Problem

I'm using MSSQL 2005 Reporting Services and in this case I need to display some reports on an ASP.NET page using the ReportViewer control (I guess thats the only way, right?). The problem is that I can't get the property `SizeToReportContent` to work. When displaying the report, I get a vertical scrollbar because the report is too large. It looks like an iframe window. Searching on google it seems to be a bug. It can be fixed by setting `AsyncRendering` to `false` but I don't want that. I need another solution. I was wondering if it's possible to set the height on the report element using JavaScript after the report has been loaded? Or do you know of another solution? This is really annoying. Thanks in advance.

Original source