Adding calendar extender causes error: Value must not be null for Controls and Behaviors RRS feed

  • Question

  • User-399055080 posted

    Our dev environment Win Server2008 r2 was upgraded this week and now I am seeing some errors in an asp.net project that i didn't (or at least notice) prior to this.  The page in question contains a placeholder control.  At runtime, we read a web user control that includes textboxes with ajax calendar extenders.  When the page renders, VS2008 shows an error "Value must not be null for Controls and Behaviors".  The page renders, but the calender extenders do not work (I assume it is because the extenders never actually were generated).  It places the debugger on a line of javascript that seems to be attempting to attach the calendar extender to the textbox.  If I remove the calender extender from the textboxes, it does not throw the exception.  We're using the AJAX 3.5 library in VS2008.  The markup for the web user control is below.

    Any idea why this has started happening?

    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ChartTemplate2.ascx.vb" Inherits="ReportPortal.ucTemplate2" %>
    <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
    <script language="javascript" type="text/javascript">
    function Progress(ImageID) {
        var img = document.getElementById(ImageID.id);
        img.src = "images/progress.gif";
        return true;
    <asp:HiddenField ID="TemplateType" runat="server" Value="CrossTable" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <asp:Panel ID="pnlChart" runat="server" Width="625px">
            <table width="100%">
                    <td width="28px">
                        <asp:ImageButton ID="cmdExcel" runat="server" Height="24px" 
                                ToolTip="Generate Excel workbook for displayed data." Width="24px"
                                style = "; top:1px; left: 1px;" />
                        <asp:ImageButton ID="cmdReport" runat="server" BorderColor="#E2E2E2" 
                            BorderStyle="None" BorderWidth="1px" Height="25px" 
                            ToolTip="Display detailed report for displayed data." Width="25px" />
                        <asp:ImageButton ID="cmdExpand" runat="server" BorderColor="#E2E2E2" 
                            BorderStyle="None" BorderWidth="1px" Height="25px" 
                            ImageUrl="~/images/expand.jpg" ToolTip="Display expanded view of chart." 
                            Width="25px" />
                        <asp:ImageButton ID="cmdPrint" runat="server" BorderColor="#E2E2E2" 
                            BorderStyle="None" BorderWidth="1px" Height="24px" 
                            ImageUrl="~/images/print.jpg" ToolTip="Print the chart." Width="24px" />
                         <asp:Label ID="lblStart" runat="server" Font-Names="Arial" Font-Size="8pt" 
                                                ForeColor="#666666" Text="Start:"></asp:Label>
                        <br />
                       <asp:TextBox ID="txtStartDate" runat="server" Font-Names="Arial" 
                                Font-Size="8pt" Width="65px"></asp:TextBox>
                            <asp:CalendarExtender ID="txtStartDate_CalendarExtender" runat="server" 
                                Enabled="True" TargetControlID="txtStartDate">
                         <asp:Label ID="lblEnd" runat="server" Font-Names="Arial" Font-Size="8pt" 
                                                ForeColor="#666666" Text="End:"></asp:Label>
                        <br />
                         <asp:TextBox ID="txtEndDate" runat="server" Font-Names="Arial" 
                                Font-Size="8pt" Width="65px"></asp:TextBox>
                             <asp:CalendarExtender ID="txtEndDate_CalendarExtender" runat="server" 
                                 Enabled="True" TargetControlID="txtEndDate">
                        <asp:Label ID="lblGroupType" runat="server" Font-Names="Arial" Font-Size="8pt" 
                            ForeColor="#666666" Text="Range Min:"></asp:Label>            
                                    <br />
                        <asp:TextBox ID="txtRangeMin" runat="server" Font-Names="Arial" Font-Size="8pt" 
                            ForeColor="#333333" Width="80px"></asp:TextBox>
                        <asp:Label ID="lblFilter" runat="server" 
    Font-Names="Arial" Font-Size="8pt" 
    Text="Range Max:"></asp:Label>
                        <br />
                        <asp:TextBox ID="txtRangeMax" runat="server" Font-Names="Arial" Font-Size="8pt" 
                            ForeColor="#333333" Width="80px"></asp:TextBox>
                            <asp:ImageButton ID="cmdRefresh" runat="server" Height="27px" 
                                ImageUrl="~/Images/refresh.jpg" ToolTip="Refresh the chart." 
                            Width="27px" OnClientClick="Progress(this);" />
                    <td style="width:100%;">
             <asp:Chart ID="chtChart" runat="server" 
                            BackGradientStyle="TopBottom" BackSecondaryColor="204, 204, 255" Height="250px" 
                            Width="625px" SuppressExceptions="True" ImageType="Jpeg" >
                            <BorderSkin SkinStyle="Raised" />
                                <asp:Title Font="Browallia New, 10pt, style=Bold" ForeColor="MidnightBlue" 
                                    Name="Title1" Text="Report Title">
                                <asp:Series Name="Series1">
                                <asp:ChartArea BackColor="224, 224, 224" BackGradientStyle="TopBottom" 
                                    BackSecondaryColor="WhiteSmoke" BorderColor="Gray" Name="ChartArea1" Area3DStyle-Inclination="25" Area3DStyle-Perspective="1">
                                    <AxisY IsLabelAutoFit="False" LabelAutoFitMinFontSize="8">
                                        <MajorGrid LineColor="DarkGray" />
                                        <LabelStyle ForeColor="MidnightBlue" Font="Calibri, 8pt" Format="N0" />
                                    <AxisX IsLabelAutoFit="False" IntervalAutoMode="FixedCount"
                                        LabelAutoFitMinFontSize="8" LabelAutoFitStyle="DecreaseFont, StaggeredLabels, LabelsAngleStep30, LabelsAngleStep45, LabelsAngleStep90, WordWrap" 
                                        TextOrientation="Rotated270" IsStartedFromZero="False" Interval="Auto">
                                        <MajorGrid LineColor="DarkGray" />
                                        <LabelStyle ForeColor="MidnightBlue" Font="Calibri, 10pt" Format="N0" 
                                            IntervalOffset="Auto" IntervalOffsetType="Auto" Angle="-45" />
                                        <LabelStyle ForeColor="MidnightBlue" />
                                    <AxisY2 IsLabelAutoFit="True" LabelAutoFitMinFontSize="8" IntervalAutoMode="FixedCount" Enabled="Auto" LabelAutoFitMaxFontSize="8" LineDashStyle="NotSet">
                                        <MajorGrid Enabled="False" />
                                        <LabelStyle ForeColor="MidnightBlue" Font="Calibri, 8pt" Format="N0" />
                                    <Area3DStyle LightStyle="Realistic" 
                                        PointDepth="50" PointGapDepth="50" Rotation="10" WallWidth="1" />
            <asp:AsyncPostBackTrigger ControlID="cmdRefresh" EventName="Click" />
    <asp:Panel ID="pnlNoData" runat="server" Width="350px" 
    BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" Height="63px" 
        <br />
        <asp:Label ID="lblTitle" runat="server" Font-Names="Browallia New" 
            Font-Size="14pt" Text="No Data Available"></asp:Label>
        <br />
        <asp:Label ID="Label1" runat="server" Font-Names="Browallia New" 
        Font-Size="14pt" Text="No Data Available" ForeColor="#CC0000"></asp:Label>
        <br />

    Here's the javascript where the exception is throw (bolded line):

    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);     }

    Friday, November 22, 2013 5:16 PM


  • User-399055080 posted

    After days of trouble-shooting this issue I have found the root of the problem.  In some cases the web user control was being assigned an ID that contained a space character.  When the server created the script for the calendar control, the space was included in the control name and that was throwing the error.  After adding code to replace spaces with underscores, the page is working as expected. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 25, 2013 1:51 PM

All replies