This is a migrated thread and some comments may be shown as answers.

[Solved] Issue with datetime picker 2011.1.315 french format not a valid datetime

7 Answers 178 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Julien
Top achievements
Rank 1
Julien asked on 28 May 2011, 09:46 PM
Hi,

I am using the latest version of DatePicker (2011.1.315) and I've got the error message :
String was not recognized as a valid DateTime
<%= Html.Telerik().DatePickerFor(model => model.DateDebut).ShowButton(true) %>

The culture of my project is set to "fr" culture (with date format as dd/mm/yyyy) and I set Telerik Globalization to true but when I have the day of the date (DateDebut) greater than the 12 of the month I get the error.

Related post: http://www.telerik.com/community/forums/aspnet-mvc/datepicker/issue-with-datetime-picker-and-non-us-date-format.aspx

Thanks for your help.
Julien

7 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 30 May 2011, 08:05 AM

Hello Julien,

 
It seems that the server, to which the formatted date is send, cannot parse it. Here is an example which shows that the datepicker works correctly on the client.

Please verify that server can parse date formatted in dd/mm/yyyy.

Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Julien
Top achievements
Rank 1
answered on 30 May 2011, 01:25 PM
Hi Georgi Krustev,

You're right, it works fine with a form using post method but I was using a form with get method and converting the string to a DateTime using DateTime.TryParse.
To fix my issue I've created a ModelBinder binding the string to a DateTime using the current culture and It's working fine.

Regards,
Julien
0
Dean
Top achievements
Rank 1
answered on 04 Jul 2011, 09:35 AM
Has this issue been fixed? Or is this always going to happen this way. I am getting the issue posting a date in british format DD MM YYYY, but it is received @ server as US format.
0
Atanas Korchev
Telerik team
answered on 04 Jul 2011, 09:39 AM
Hi Dean,

Is the date posted correctly if you use Html.TextBox instead of the datepicker? If it doesn't then there may be a problem which is not related to Telerik extensions for asp.net mvc.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dean
Top achievements
Rank 1
answered on 04 Jul 2011, 10:31 AM
Hi

If I set a model with a DateTime theDate and a String theString, and set them both to DateTime.Today in the controller.

Then have a view with 2 Text controls for the ViewModel, they are both shown as 04/07/2011  (correct for UK). If I then use a submit button to do a  HTTPGET , theDate has 07/04/2011 and the theString has 04/07/2011.

I have checked the CurrentCulture and CurrentUICulture, and this happens when both are en-GB.
0
Atanas Korchev
Telerik team
answered on 04 Jul 2011, 11:39 AM
Hi Dean,

This sounds like a known behavior of the model binder. You can find more info in this blog post.

Regards,

Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dean
Top achievements
Rank 1
answered on 04 Jul 2011, 05:01 PM
Thanks, it is not a Telerik problem.

I have tried those suggestions, and it does not completely fix my problem.

Some dates might be a 'Post' and some a 'Get', and this is causing the date to switch from GB to US, and I don't know how to differentiate.
Tags
Date/Time Pickers
Asked by
Julien
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Julien
Top achievements
Rank 1
Dean
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or