.net 报表查看器 Web 控件需要 Web 窗体上的 System.Web.UI.ScriptManager
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11521984/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The Report Viewer Web Control requires a System.Web.UI.ScriptManager on the web form
提问by user1531667
I have tried to call a .rdl report created in SSRS to be called in an aspx page; but I got the following error:
我试图调用在 SSRS 中创建的 .rdl 报告在 aspx 页面中调用;但我收到以下错误:
The Report Viewer Web Control requires a
System.Web.UI.ScriptManageron the web form
报表查看器 Web 控件需要一个
System.Web.UI.ScriptManagerWeb 表单
My Code is as follows,
我的代码如下,
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();
}
Any help is appreciated.
任何帮助表示赞赏。
回答by Graham Laight
On the report form, add a script manager from the toolbox before the report control: open the toolbox and select Ajax Extensions - Script Manager, then drag it onto the form. Using Visual Studio 2012, what I ended up with was the following new control on the form:
在报表上,从工具箱中的报表控件之前添加一个脚本管理器:打开工具箱,选择Ajax Extensions - Script Manager,然后将其拖到窗体上。使用 Visual Studio 2012,我最终得到的是表单上的以下新控件:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
Full details for Visual Studio 2012 at http://msdn.microsoft.com/en-us/library/ms252104.aspx
有关 Visual Studio 2012 的完整详细信息,请访问http://msdn.microsoft.com/en-us/library/ms252104.aspx

