Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft ReportViewer Web Control Requiring a ScriptManager

I'm trying to render the report viewer programmatically within a custom Page placed in an IHttpHandler context

ReportViewer rv = new ReportViewer();
ReportDataSource rds = new ReportDataSource();
rds.Name = "Report";
rv.LocalReport.ReportPath = "Report.rdlc";

rds.Value = SomeReportObject;

rv.LocalReport.DataSources.Add(rds);
rv.LocalReport.Refresh();

ScriptManager scriptHandler = new ScriptManager();
MyPage p = new MyPage();
p.Controls.Add(scriptHandler);
p.Controls.Add(rv);

using (TextWriter myTextWriter = new StringWriter())
        {
            using (HtmlTextWriter myWriter = new HtmlTextWriter(myTextWriter))
            {
               p.RenderControl(myWriter);
            }
        }

Although I have the ScriptManager added to the page but the runtime complains that the ReportViewer needs one, it throws the following exception at p.RenderControl(myWriter) line

The Report Viewer Web Control requires a System.Web.UI.ScriptManager on the web form.

And this is the MyPage Class

public class MyPage : Page
{

    public override void VerifyRenderingInServerForm(Control control)
    {
        //Empty Method
    }

    public override bool EnableEventValidation
    {
        get { return false; }
        set { /* Do nothing */}
    }
}

Any help would be very appreciated. This is done on .NET 4 and I'm using ReportViewer 2010.

like image 496
Maya Avatar asked May 08 '10 20:05

Maya


People also ask

What is microsoft ReportViewer?

Description: Microsoft Report Viewer is a software that enables applications that run on the Microsoft . NET Framework to display reports designed using the Microsoft reporting technology.

What is Microsoft Report Viewer 2015?

MICROSOFT® REPORT VIEWER 2015 RUNTIME The Microsoft Report Viewer control enables applications that run on the . NET Framework to display reports designed using Microsoft reporting technology. This redistributable package contains Windows and Web versions of the Report Viewer.


1 Answers

In my case just put the instruction

<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

in the aspx form source mode and works!!

like image 114
Jorge olivares Avatar answered Sep 19 '22 20:09

Jorge olivares