Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have tried to call a .rdl report created in SSRS to be called in an aspx page; but I got the following error:

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

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.

like image 820
user1531667 Avatar asked Jul 17 '12 11:07

user1531667


1 Answers

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:

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

Full details for Visual Studio 2012 at http://msdn.microsoft.com/en-us/library/ms252104.aspx

like image 94
Graham Laight Avatar answered Sep 21 '22 16:09

Graham Laight