Date.parseLocale Bug In ASP.NET Ajax Control Toolkit

14 June 2007

So I ran into a weird one tonight. I have an ASP.NET page with a grid view and some text boxes. Two of the text boxes have CalendarExtenders on them. On initial load everything is peachy. But I select something in the Grid and fill in the values of the two text boxes on the server side...things go awry. I'm getting a javascript error, "Date.parseLocale is not a function".

There is a lengthy discussion of this in a post on the ASP.NET forums. Apparently this is a known issue. The last poster said it was fixed in a later version, but I'm using the latest and it definitely isn't.

However, one of the forum users posted a hack to get this working. And indeed it does. You just have to put this in the Page_Load function of the page that has the controls:

   1:  //Hack I found here: http://forums.asp.net/t/1068191.aspx
   2:  if (ScriptManager.GetCurrent(this.Page) != null)
   3:  {
   4:      if (!Page.ClientScript.IsStartupScriptRegistered("AjaxToolkitTempFix"))
   5:      {
   6:          Page.ClientScript.RegisterStartupScript(this.GetType(), "AjaxToolkitTempFix", "Date.parseLocale = function(s, f){return Date(s);};" + Environment.NewLine + "Sys.Debug = new Object();Sys.Debug.isDebug =  function(){return true};", true);
   7:      }
   8:  }
   9:  

Hope it works for you as well. Enjoy. I would put a note about how this doesn't work in the newest version and the hack is still necessary, but I kept getting a 404 when trying to login to the forums :)

Comments:2
Comments
  1. RushWebsiteon Fri, 31 Aug 2007 00:31:24 GMT
    Thanks for posting about this. I wouldn't have gone through the trouble of looking through the forums but a quick google search is painless, and it worked! :-) I haven't tried the latest version though, maybe I should.
  2. Ericon Sat, 01 Sep 2007 09:53:59 GMT
    I haven't tried to see if it's been fixed recently. If you find that it is, drop a note. I'd appreciate it.
Name:
Blog or Website:
 
Email (will not be displayed):
 
Comment :