报表查看器Web控件需要Web表单上的System.Web.UI.ScriptManager

时间:2012-07-17 11:57:07

标签: .net reporting-services rdl

我试图调用在SSRS中创建的.rdl报告,以便在aspx页面中调用;但是我收到了以下错误:

  

报表查看器Web控件需要Web表单上的System.Web.UI.ScriptManager

我的代码如下,

protected void Page_Load(object sender, EventArgs e)
{
    //string query = Session["ClosedBugsResult1"].ToString();

    if(!IsPostBack)
    ReportViewer1.ProcessingMode = ProcessingMode.Remote; 
    ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://localhost/reportserver"); 
    ReportViewer1.ServerReport.ReportPath = @"D:\Users\XXX\Documents\Visual Studio 2008\Projects\BugtrackerSample1\BugTrackerSample\BugTrackerSample\Report1.rdl"; 

    //ReportParameter[] param = new ReportParameter[1]; 
    //param[0] = new ReportParameter("CustomerID", txtparam.Text);
    //ReportViewer1.ServerReport.SetParameters(param);
    System.Web.UI.ScriptManager scriptManager = new ScriptManager(); 
    Page page = new Page();
    System.Web.UI.HtmlControls.HtmlForm form = new HtmlForm();
    form.Controls.Add(scriptManager); 
    form.Controls.Add(ReportViewer1); 
    page.Controls.Add(form);
    page.DataBind();  //exception here 
    ReportViewer1.ServerReport.Refresh();
}

感谢任何帮助。

1 个答案:

答案 0 :(得分:30)

在报表上,在报表控件之前从工具箱中添加一个脚本管理器:打开工具箱并选择Ajax Extensions - Script Manager,然后将其拖到表单上。使用Visual Studio 2012,我最终得到的是表单上的以下新控件:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

http://msdn.microsoft.com/en-us/library/ms252104.aspx

上的Visual Studio 2012的完整详细信息