View Full Version : [FIXED] DatePicker date format dd/MM/yyyy not working

Feb 27, 2008, 4:39 AM
I'm using the DatePicker control and I can't get the date showing in format dd/MM/yyyy. It seems the Format property is not working at all. Am I missing something?

Feb 27, 2008, 2:27 PM
Hi alterin,

Unfortunately the date formatting within the DatePicker is one (if not the only) place where there is a serious disconnect/conflict between the ExtJS framework and .NET.

Ext uses a PHP/Unix style of date format specifiers, which is not compatible with the .NET/Java syntax.

At the moment I do not have a good solution for this, but it will be fixed in an upcoming release (not 0.4, but probably 0.5). For now the "MM/dd/yyyy" is the only format that will reliably work.

Feb 28, 2008, 3:22 AM

I ended up with

"dd.MM.yyyy".Replace("dd", "d").Replace("MM", "m").Replace("yyyy", "Y")

Mar 21, 2008, 9:51 AM
Even without specifying format, there is a bug. I'm just using:

<cool:DatePicker ID="DatePickerMapDate" runat="server" />

And on each post back the days and month swaps (i.e. I put 01/03/08 and after a postback the date changes to 03/01/08). Furthermore, I can never select a day > than 12 otherwise I get:

[FormatException: String was not recognized as a valid DateTime.]
System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +2273210
System.DateTime.Parse(String s) +22
Coolite.Web.UI.DatePicker.get_SelectedDate() +110
Coolite.Web.UI.DatePicker.LoadPostData(String postDataKey, NameValueCollection postCollection) +170
Coolite.Web.UI.Field.System.Web.UI.IPostBackDataHa ndler.LoadPostData(String postDataKey, NameValueCollection postCollection) +11
System.Web.UI.Page.ProcessPostData(NameValueCollec tion postData, Boolean fBeforeLoad) +661
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1194

I think this is related to the swaping day/month.

Another bug is that when it's inside an UpdatePanel, on postbacks, there's a duplicate calendar icon for the calendar textbox (both icons are functional; the duplicate icon appears at the begining of the textbox, hiding the day)

Mar 25, 2008, 8:58 PM
The bug with duplicate icons is due to the recreation of the date picker (reinitialization of the ext object). When the control is in an updatepanel, and that the panel is being recreated through an async postback, the bug doesn't occur (it's doing what it's supposed to; recreating the control). But when the update panel is not being updated, the control doesn't need to be recreated. Doing so, creates a duplicate button.

As for the bug about the format, you guys can use the parseExact instead of just parse, so that months and days doesn't get swapped on PCs that has different regional settings.

Hope it helps,

PS: Great job btw, can't wait for the next release.

Mar 25, 2008, 9:05 PM
Hi Dan,

I apologize for not responding earlier. I've been tinkering with the DatePicker today and have the date parsing working correctly. I'm diving back into the DatePicker later today, so I'll post an update if I find a work-around to use with the current (0.4.1) release. Otherwise, the new code/fix will be included with the next release.

I was also changing up the how the onReady script gets generated when the controls are in an Async postback. It's been a bit tricky to get this all working with the UpdatePanel, but everything should be working smoothly for the next release.

Mar 25, 2008, 9:08 PM
Thanks for the reply,

Yeah I figured it was tricky. I created a user control in order to fix the bug and I noticed the challenge. I ended up caling my reinitialize ext component function manually whenever I'm updating my update panel. Not ideal, but it's a quick fix :)

Apr 12, 2008, 3:56 PM

I managed to fix this problem.
This is what i did to setup the DatePicker for working with Dutch dateformats:

1) include the .js localisation file from the Ext sourcecode (called ext-lang-nl.js in my case) on the page.
2) doublecheck that the Ext DateField settings in this file are appropriate for your country (see Ext docs Date object), in my case they are:

format : "d-m-Y",
altFormats : "d-m-y|j-n-y|j-n-Y|d/m/y|j/n/y|j/n/Y",

3) make sure that you set the Format property of the Coolite DatePicker server control to a .Net dateformat string, in my case:

dp = new Coolite.Web.UI.DatePicker{
Format = "dd-MM-yyyy",

I hope this helps.


Jun 06, 2008, 2:28 AM
These DateFormat and UpdatePanel bugs have been fixed in the 0.5 release (http://www.ext.net/download/).

Please let me know if you run into any issues and we'll do our best to patch immediately.