I've updated some code to use the Ajax Control toolkit 0911 beta and for some reason code that dynamically added collapsable panel extenders in the code behind now causes the following error in the client side jscript...
Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls and Behaviors. Parameter name: element
in...
$create = Sys.Component.create = function Sys$Component$create(type, properties, events, references, element) {
/// <summary locid="M:J#Sys.Component.create" />
/// <param name="type" type="Type"></param>
/// <param name="properties" optional="true" mayBeNull="true"></param>
/// <param name="events" optional="true" mayBeNull="true"></param>
/// <param name="references" optional="true" mayBeNull="true"></param>
/// <param name="element" domElement="true" optional="true" mayBeNull="true"></param>
/// <returns type="Object"></returns>
var e = Function._validateParams(arguments, [
{name: "type", type: Type},
{name: "properties", mayBeNull: true, optional: true},
{name: "events", mayBeNull: true, optional: true},
{name: "references", mayBeNull: true, optional: true},
{name: "element", mayBeNull: true, domElement: true, optional: true}
]);
if (e) throw e;
if (type.inheritsFrom(Sys.UI.Behavior) || type.inheritsFrom(Sys.UI.Control)) {
if (!element) throw Error.argument('element', Sys.Res.createNoDom);
}
I accept that this is only a beta but I'm unable to either find a work around or even understand the reason why this pretty simple code no longer works.
Code
private Panel GetReportPanel(DataRow dr, ReportParameter[] Params)
{
Panel pnlReport = new Panel();
pnlReport.ID = Uri.EscapeDataString(dr["ReportName"].ToString()) + "_MainReportContainer";
//Report Title Section
var pnlReportTitle = new Panel();
pnlReportTitle.CssClass = "ReportSectionTitle";
var tblReportTitle = new Table();
var trowReportTitle = new TableRow();
var tcellReportTitle = new TableCell();
var imgReportTitleExpand = new Image();
imgReportTitleExpand.ID = Uri.EscapeDataString("img" + dr["ReportName"].ToString() + "DataExpand");
tcellReportTitle.Controls.Add(imgReportTitleExpand);
trowReportTitle.Controls.Add(tcellReportTitle);
tcellReportTitle = new TableCell();
var lblReportTitle = new Label();
lblReportTitle.ID = Uri.EscapeDataString("lnk" + dr["ReportName"].ToString());
lblReportTitle.Text = "Functional " + dr["ReportName"].ToString();
tcellReportTitle.Controls.Add(lblReportTitle);
trowReportTitle.Controls.Add(tcellReportTitle);
tblReportTitle.Controls.Add(trowReportTitle);
pnlReportTitle.Controls.Add(tblReportTitle);
pnlReport.Controls.Add(pnlReportTitle);
//Report Section
var pnlReportSection = new Panel();
pnlReportSection.ID = Uri.EscapeDataString("pnlReportSection" + dr["ReportName"].ToString());
pnlReportSection.CssClass = "ReportSection";
pnlReportSection.ScrollBars = ScrollBars.None;
var pnlInnerReportSection = new Panel();
pnlInnerReportSection.CssClass = "ReportSection";
var rptControl = new ReportViewer();
rptControl.ID = "rpt" + dr["ReportName"].ToString().Replace(' ', '_');
rptControl.ProcessingMode = ProcessingMode.Remote;
rptControl.Width = new Unit("100%");
rptControl.ShowDocumentMapButton = false;
rptControl.ShowParameterPrompts = false;
rptControl.Visible = true;
rptControl.Height = new Unit("500px");
rptControl.AsyncRendering = (bool)dr["ASyncRenderingEnabled"];
rptControl.ServerReport.ReportPath = dr["SSRSReportPath"].ToString();
rptControl.ServerReport.ReportServerUrl = new Uri("http://horoap336/reportserver");
rptControl.ServerReport.SetParameters(Params);
pnlInnerReportSection.Controls.Add(rptControl);
pnlReportSection.Controls.Add(pnlInnerReportSection);
pnlReport.Controls.Add(pnlReportSection);
//Collapsable Panel Extender
var Extender = new AjaxControlToolkit.CollapsiblePanelExtender();
Extender.TargetControlID = pnlReportSection.ID;
Extender.ID = Uri.EscapeDataString(dr["ReportName"].ToString()) + "_Extender";
Extender.CollapsedSize = 0;
Extender.Collapsed = true;
Extender.ExpandControlID = lblReportTitle.ID;
Extender.CollapseControlID = lblReportTitle.ID;
Extender.AutoCollapse = false;
Extender.AutoExpand = false;
Extender.ScrollContents = false;
Extender.TextLabelID = lblReportTitle.ID;
Extender.CollapsedText = "Functional " + dr["ReportName"].ToString() + " (Click To Show Details...)";
Extender.ExpandedText = "Functional " + dr["ReportName"].ToString() + " (Click To Hide Details...)";
Extender.ImageControlID = imgReportTitleExpand.ID;
Extender.ExpandedImage = "~/images/collapse.jpg";
Extender.CollapsedImage = "~/images/expand.jpg";
Extender.ExpandDirection = AjaxControlToolkit.CollapsiblePanelExpandDirection.Vertical;
pnlReport.Controls.Add(Extender);
return pnlReport;
}
This panel is then added to a panel in the aspx file using...
pnlContainer.Controls.Add(GetReportPanel(dr,Params));
Aspx file...
<%@ Page Title="Operations MI Dashboard - Functional Reporting" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="FunctionalReport.aspx.cs" Inherits="TelephonyReport" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Panel ID="pnlContainer" runat="server">
</asp:Panel>
</asp:Content>
So, my questions are:
- Is there a problem with my code that is only evident in the later version of the toolkit?
- Does anyone know of a workaround that I can try?
- Can anyone explain why this problem happens only in the latest version?