Answered by:
CalendarExtender and javascript error

Question
-
User1310055179 posted
Hi,
Did anyone run into the following javascript error while using the CalendarExtender?
Uncaught Sys.ArgumentException: Sys.ArgumentException: Value must not be null for Controls and Behaviors. Parameter name: element
The error appears in the following javascript function (chrome browser):
$create = $type.create = function Component$create(type, properties, events, references, element) { /// <summary locid="M:J#Sys.Component.create">Instantiates a component of the specified type, attaches it to the specified element if it's a Control or Behavior, sets the properties as described by the specified JSON object, then calls initialize.</summary> /// <param name="type" type="Type">The type of the component to create.</param> /// <param name="properties" optional="true" mayBeNull="true">A JSON object that describes the properties and their values.</param> /// <param name="events" optional="true" mayBeNull="true">A JSON object that describes the events and their handlers.</param> /// <param name="references" optional="true" mayBeNull="true">A JSON object that describes the properties that are references to other components. The contents of this object consists of name/id pairs. If in a two-pass creation, the setting of these properties will be delayed until the second pass.</param> /// <param name="element" domElement="true" optional="true" mayBeNull="true">The DOM element the component must be attached to.</param> /// <returns type="Object">The component instance.</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); } else if (element) throw Error.argument('element', Sys.Res.createComponentOnDom); var component = (element ? new type(element): new type()); callIf(component, "beginUpdate"); if (properties) { Sys.Component._setProperties(component, properties); } if (events) { for (var name in events) { if (!(component["add_" + name] instanceof Function)) throw new Error.invalidOperation(String.format(Sys.Res.undefinedEvent, name)); if (!(events[name] instanceof Function)) throw new Error.invalidOperation(Sys.Res.eventHandlerNotFunction); component["add_" + name](events[name]); } } Sys.Component._register(component, references); return component; }
I am building a dynamic form and I add the extender and the textbox control from codebehind.
Unfortunatelly I sometimes get the above javascript error. I have no idea why in some cases it appears and others it doesn't.
I would really appreciate your help with that.
Thanks
Monday, October 13, 2014 5:04 AM
Answers
-
User555306248 posted
Hi,
This is a real problem in AjaxControlToolkit v3.5 and v4.0. But it works fine for AjaxControlToolkit v3.0.
This is because of the $get() function. The parameter will send to validate rather than send to the document.getElementById() directly. And I don't think it is a big problem, actually, we all suggest to use standard characters to name the controls.
http://ajaxcontroltoolkit.codeplex.com/workitem/27439
http://forums.asp.net/t/1620879.aspx
http://forums.asp.net/t/1973404.aspx?+Value+must+not+be+null
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, October 19, 2014 11:34 PM
All replies
-
User61956409 posted
Hi qsoft,
Thanks for your post.
I am building a dynamic form and I add the extender and the textbox control from codebehind.According to your description, I create a demo to test in IE11, the code works fine on my side. You could compare your code with the following sample to find some differences.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager> <div> <b>Default calendar: </b> <br /> <asp:Panel ID="Panel1" runat="server"></asp:Panel> </div> </form> </body> </html>
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { TextBox tb = new TextBox(); tb.ID = "Date1"; CalendarExtender defaultCalendarExtender = new CalendarExtender(); defaultCalendarExtender.ID = "calendarExtender1"; defaultCalendarExtender.TargetControlID = "Date1"; Panel1.Controls.Add(tb); Panel1.Controls.Add(defaultCalendarExtender); } }
The error appears in the following javascript function (chrome browser):Besides, you get the error in chrome browser, so you could post your problem in Chrome Help Forum for professional help.
Hope it will be helpful to you.
Best Regards,
Fei Han
Monday, October 13, 2014 10:44 PM -
User555306248 posted
Hi,
This is a real problem in AjaxControlToolkit v3.5 and v4.0. But it works fine for AjaxControlToolkit v3.0.
This is because of the $get() function. The parameter will send to validate rather than send to the document.getElementById() directly. And I don't think it is a big problem, actually, we all suggest to use standard characters to name the controls.
http://ajaxcontroltoolkit.codeplex.com/workitem/27439
http://forums.asp.net/t/1620879.aspx
http://forums.asp.net/t/1973404.aspx?+Value+must+not+be+null
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, October 19, 2014 11:34 PM