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.
Following your codes, I've made similar ones for the CalendarExtender, but can't get them to work.
- On page load, the SelectedDate doesn't show up in the TextBox.
- Clicking on the TextBox pops the calendar, but any date selected there still doesn't go into the TextBox.
- After closing the page, I get this error...
Microsoft JScript runtime error: Sys.ArgumentUndefinedException: Value cannot be undefined.
Parameter name: array
My client script must be wrong. Please help. Thanks!
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
' original TextBox ID containing unicode
Dim textbox As New TextBox
textbox.ID = "TextBox1"
textbox.Text = ""
' add a hidden TextBox with a correct ID
Dim hiddentextbox As New TextBox
hiddentextbox.ID = "hidden"
hiddentextbox.Style.Add(HtmlTextWriterStyle.Display, "none")
Page.Form.Controls.Add(hiddentextbox)
' set the targetcontrolid as the hidden textbox
Dim calendarextender As New AjaxControlToolkit.CalendarExtender
calendarextender.ID = "CalendarExtender1"
calendarextender.TargetControlID = hiddentextbox.UniqueID
calendarextender.SelectedDate = Today
' add these controls
PlaceHolder1.Controls.Add(textbox)
PlaceHolder1.Controls.Add(calendarextender)
' add a client script to fix the bug.
ScriptManager.RegisterStartupScript(Me, Me.GetType, "fixbug", "Sys.Application.add_load(function(){var a=$find('" & calendarextender.UniqueID & "');a._element=document.getElementById('" & textbox.UniqueID & "');a.initialize();});", True)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' original TextBox ID containing unicode
Dim textbox As New TextBox
textbox.ID = "TextBox1"
textbox.Text = ""
' add a hidden TextBox with a correct ID
Dim hiddentextbox As New TextBox
hiddentextbox.ID = "hidden"
hiddentextbox.Style.Add(HtmlTextWriterStyle.Display, "none")
Page.Form.Controls.Add(hiddentextbox)
' set the targetcontrolid as the hidden textbox
Dim calendarextender As New AjaxControlToolkit.CalendarExtender
calendarextender.ID = "FakeCE"
calendarextender.TargetControlID = hiddentextbox.UniqueID
calendarextender.SelectedDate = Today
' add these controls
PlaceHolder1.Controls.Add(textbox)
PlaceHolder1.Controls.Add(calendarextender)
' add a client script to fix the bug.
ScriptManager.RegisterStartupScript(Me, Me.GetType, "fixbug", _
"Sys.Application.add_load(function(){$create(Sys.Extended.UI.CalendarBehavior, {'id':'CalendarExtender1','selectedDate':(new Date()).toString()}, null, null, document.getElementById('" + textbox.ClientID + "'));});", True)
End Sub
Member
11 Points
39 Posts
Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls and B...
Nov 07, 2010 11:41 PM|Cedric Chinnok|LINK
error:
Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls and Behaviors. Parameter name: element
cause:
asp:CalendarExtender TargetControlID (asp:TextBox ID) contains unicode, for instance "TextBox1"
workaround:
change asp:CalendarExtender TargetControlID (asp:TextBox ID) to entirely ascii, for instance "TextBox1"
Don't know whether it's a bug or me only, so would appreciate if someone could run it and confirm. Thanks in advance!
All-Star
22811 Points
3441 Posts
Re: Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls a...
Nov 09, 2010 09:43 PM|Jerry Weng - MSFT|LINK
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.
Member
11 Points
39 Posts
Re: Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls a...
Nov 10, 2010 06:25 AM|Cedric Chinnok|LINK
@Jerry Weng - MSFT
I found a similar case, where you provided a workaround for the TextBoxWatermarkExtender.
http://forums.asp.net/p/1619942/4159901.aspx
Following your codes, I've made similar ones for the CalendarExtender, but can't get them to work.
- On page load, the SelectedDate doesn't show up in the TextBox.
- Clicking on the TextBox pops the calendar, but any date selected there still doesn't go into the TextBox.
- After closing the page, I get this error...
Microsoft JScript runtime error: Sys.ArgumentUndefinedException: Value cannot be undefined.
Parameter name: array
My client script must be wrong. Please help. Thanks!
All-Star
22811 Points
3441 Posts
Re: Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls a...
Nov 10, 2010 09:29 PM|Jerry Weng - MSFT|LINK
Hi,