New to Telerik Reporting? Download free 30-day trial

Using the ASP.NET WebForms Report Viewer

This is a legacy report viewer and for new projects our recommendation is to use the latest WebForms Report Viewer - HTML5 Web Forms Report Viewer

Assign report to the viewer in design time

To use Telerik Reports in web application, you need the Web report viewer:

  1. Drag the ReportViewer control from the Toolbox to the design surface of a web form.

    An image demonstrating how the ASP.NET WebForms Report Viewer can be inserted from the Visual Studio Toolbox

    By doing so, the ReportViewer control would register automatically the HTTP handler it needs to function properly in the web.config file of the web application/site.

    The HTTP handler is automatically registered in the web.config only when the report viewer control is dropped from the Toolbox to the design surface of a web form. If you drop the report viewer in the text editor (source view) or add it to the web form programatically, you should manually register the HTTP handler using the XML markup below, where x.x.x.x is your Telerik Reporting assembly version.

    In the <system.web>/<httpHandlers> section:

    <system.web>
    ....
        <httpHandlers>
            <add path="Telerik.ReportViewer.axd" verb="*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=x.x.x.x, Culture=neutral, PublicKeyToken=a9d7983dfcc261be"/>
        </httpHandlers>
    ....
    </system.web>
    

    In the <system.webServer>/<handlers> section:

    <system.webServer>
        <handlers>
            <add name="Telerik.ReportViewer.axd_*" path="Telerik.ReportViewer.axd" verb="*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=x.x.x.x, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" preCondition="integratedMode"/>
        </handlers>
        <validation validateIntegratedModeConfiguration="false"/>
    </system.webServer>
    
  2. Add reference to the class library that contains your reports in the web application/site.

  3. Build the application

  4. Set the ReportSource for the report viewer. For more information, see How to Set ReportSource for Report Viewers

Assign report to the viewer programatically

In the Page_Load event handler, create an TypeReportSource and set its TypeName property to the Type.AssemblyQualifiedName property. Next assign the TypeReportSource instance to the ReportSource property of the viewer.

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        var typeReportSource = new Telerik.Reporting.TypeReportSource();
        typeReportSource.TypeName = "Telerik.Reporting.Examples.CSharp.ListBoundReport, CSharp.ReportLibrary";
        this.ReportViewer1.ReportSource = typeReportSource;
    }
}
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not IsPostBack Then
        Dim typeReportSource As New Telerik.Reporting.TypeReportSource()
        typeReportSource.TypeName = "ListBoundReport, VB.ReportLibrary"
        ReportViewer1.ReportSource = typeReportSource
        ReportViewer1.RefreshReport()
    End If
End Sub

See Also

In this article