Freigeben über


SYSK 380: How to Get Rid of Double Scroll Bar in Microsoft Report Viewer Control

Special thanks to David Petersen who has submitted this post!

 

If you ASP.NET page that contains the Report Viewer Control, has double scroll bars, you can remove them by including two separate form elements on the page:

1. First <form> element Includes your Headers and so forth (notice the absence of runat=”server” attribute in the example below). This form can also inherit Web User Controls.

2. The second <form> element is the one that includes the Report Viewer Control, and is a server side form. This way you can dynamically populate the report viewer control in the code behind.

 

 

web.config:

 

<httpHandlers>

  <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms,

  Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>

</httpHandlers>

<buildProviders>

 <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral,

  PublicKeyToken=b03f5f7f11d50a3a"/>

</buildProviders>

<system.webServer>

<add name="ReportViewerWebControl" path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler,

Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

</system.webServer>

 

webpage.aspx:

 

<%@ Page language="c#" Inherits="ReportViewerPage" CodeFile="ReportViewerPage.aspx.cs"

    Description="Report Viewer Page" Title="Report Viewer Page" %>

<%@ Register TagPrefix="rsweb" Namespace="ReportViewer" Assembly="ReportViewer" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head id="Head1" runat="server">

    <title>Report Viewer Page</title>

<style type="text/css">

       html, body, form

       {width: 100%; height:88%; margin:0; padding:0; }

       body {overflow-y:hidden;}table#ReportViewer1{display:table !important;}

</style>

</head>

<body>

    <form id="headerForm" name="header" action="#" style="height:5%">

          <table id="headerTable">

                <tr>

                  <td></td>

                </tr>

            </table>

    </form>

    <form id="controlForm" name="reportForm" runat="server" action="#">

        <ajax:ToolkitScriptManager ID="ScriptManager1" runat="server"

            EnablePageMethods="true"

            CombineScripts="false"

            EnablePartialRendering="true">

        </ajax:ToolkitScriptManager>

        <rsweb:ReportViewer ID="reportViewer" runat="server" Font-Names="Verdana"

            Font-Size="8pt" ProcessingMode="Remote" Height="100%" Width="100%">

        </rsweb:ReportViewer>

    </form>

</body>

</html>

 

webpage.aspx.cs

private void RenderReport(string reportPath, string systemBaseURL)

{

reportViewer.ServerUrl = systemBaseURL;

      reportViewer.ReportPath = reportPath;

}

ReportViewer.cs

/*=====================================================================

  File: ReportViewer.cs

  Summary: Main class for the Microsoft SQL Server Reporting Services sample

                  server control.

---------------------------------------------------------------------

  This file is part of Microsoft SQL Server Code Samples.

 

  Copyright (C) Microsoft Corporation. All rights reserved.

 This source code is intended only as a supplement to Microsoft

 Development Tools and/or on-line documentation. See these other

 materials for detailed information regarding Microsoft code samples.

 THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY

 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE

 IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A

 PARTICULAR PURPOSE.

=====================================================================*/

using System;

using System.ComponentModel;

using System.Collections;

using System.Collections.Specialized;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Drawing.Design;

using System.Drawing;

namespace ReportViewer

{

      public class ReportViewer : WebControl

      {

           . . .

      }

}

Comments

  • Anonymous
    September 25, 2010
    Wow..Sharing this. ;-)

  • Anonymous
    September 27, 2010
    Thanks David, for sharing this. It would be help to lot of people.

  • Anonymous
    September 28, 2010
    Will this work with version 10.0 of the report viewer control?