ReportViewerWebWebpart显示报表时显示的脚本错误:Uncaught Sys.ArgumentNullException: Sys.ArgumentNullException: 值不能为 null。参数名: panelsCreated[0]

原因可能有三个:

1、ReportService版本太低,所以可以升级Sql Server 2008 R2 SP2.
 
2、母版页中的ScriptManager的属性加上ScriptMode="Release"
 
3、在站点的web.config中将设置为<compilation batch="false" debug="false" optimizeCompilations="true">,其主要原因是debug为true的时候会出现这个错误。
 
其中第1、2个可能都不是主要原因,但我在测试的时候由于已经安装了SP2,所以也不可能把它卸载后再去测试,估且这样认为吧。
 
另外附上控制ReportViewerWebPart过滤参数以及控制缩放的方法:
 
在页面的后台代码中加入(或者直接写到aspx文件中):
 
        protected override void OnLoad(EventArgs e)
        {
            if (!this.IsPostBack)
            {
                ReportViewerWebPart viewer = FindMainWebpart<ReportViewerWebPart>();
                if (viewer != null)
                {
                    viewer.OverrideParameters.Clear();
                    viewer.OverrideParameters.Add(new Microsoft.Reporting.WebForms.ReportParameter("aa", "13,14", false));
                ReportViewer rptViewer = ReflectorUtils.getField<ReportViewer>("m_reportViewer", viewer);
                rptViewer.ZoomMode = ZoomMode.PageWidth;
                }
            }

            base.OnLoad(e);
        }

        /// <summary>
        /// 找到页面的Webpart
        /// </summary>
        /// <param name="webPartZoneId">WebpartZone的Id</param>
        /// <returns></returns>
        protected T FindWebpart<T>(string webPartZoneId) where T : Microsoft.SharePoint.WebPartPages.WebPart
        {

            #region 已注释:通过Master找特定WebPartZone的控件

            //1.此种方式只能获取指定区域的Webpart
            //ContentPlaceHolder holder =(ContentPlaceHolder)Master.FindControl("PlaceHolderMain");
            //if (holder != null)
            //{
            //    WebPartZone zone = (WebPartZone)holder.FindControl("Main");
            //    foreach (WebPart control in zone.WebParts)
            //    {
            //        if (control is XsltListViewWebPart)
            //        {

            //        }
            //    }
            //}

            #endregion

            T result = default(T);

            SPWebPartManager sPWebPartManager = SPWebPartManagerInPage;
            if ((sPWebPartManager.Zones != null) && (sPWebPartManager.Zones.Count > 0))
            {
                foreach (Microsoft.SharePoint.WebPartPages.WebPartZone zone in sPWebPartManager.Zones)
                {
                    if (zone.ID == webPartZoneId)
                    {
                        foreach (Microsoft.SharePoint.WebPartPages.WebPart webpart in zone.WebParts)
                        {
                            if (webpart is T)
                            {
                                result = (T)webpart;
                                break;
                            }
                        }
                    }
                    if (result != null)
                    {
                        break;
                    }
                }
            }
            return result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        protected T FindMainWebpart<T>() where T : Microsoft.SharePoint.WebPartPages.WebPart
        {
            return FindWebpart<T>("Main");
        }

 

你可能感兴趣的:(ReportViewerWebWebpart显示报表时显示的脚本错误:Uncaught Sys.ArgumentNullException: Sys.ArgumentNullException: 值不能为 null。参数名: panelsCreated[0])