Microsoft ReportViewer Web控件需要ScriptManager [英] Microsoft ReportViewer Web Control Requiring a ScriptManager

查看:178
本文介绍了Microsoft ReportViewer Web控件需要ScriptManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在置于IHttpHandler上下文中的自定义页面中以编程方式呈现报表查看器

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);
            }
        }

尽管我在页面上添加了ScriptManager,但是运行时抱怨ReportViewer需要一个,它在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

Report Viewer Web控件需要一个System.Web。 Web表单上的UI.ScriptManager。

这是MyPage类

public class MyPage : Page
{

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

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

任何帮助将不胜感激。这是在.NET 4上完成的,而我正在使用ReportViewer 2010。

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

推荐答案

在我的情况下,只需输入指令

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>

在aspx表单源模式下有效!

in the aspx form source mode and works!!

这篇关于Microsoft ReportViewer Web控件需要ScriptManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆