0

I have a probleme with date picker I have already created controllers with read/write actions and views using EF everything was OK Till I have need to create a controller with a modelView so I chosed an empty controller and I created the views by myself The problem is when I use datepicker with dd/MM/yy it is shown OK but when I check the value sent to the server it's null if day is >12 I tried to introduce 02/19/2008 it accepts it in the server it is sent as 19/02/2008 I didn't understand why I try to set globalization culture and uiculture to en-US en-GB fr-FR nothing work Is there a way to specify how date picker parse the date( I already used the datepicker.parseDate) Need your help please

Minoucha
  • 11
  • 2

2 Answers2

0

You could specify the desired format when creating the datepicker:

$('#datepicker').datepicker({ dateFormat: 'dd/mm/yyyy' })

Now you should also make sure that your server uses the same format for parsing the date either by specifying a culture or you could also write a custom model binder for the DateTime type.

Community
  • 1
  • 1
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • I did that, how I can check if the server uses the same format – Minoucha Oct 03 '12 at 09:45
  • The server uses the format that is specified in the globalization element in your web.config. If it is set to auto (default) it will use the client browser's settings Accept Language request header to set the culture. – Darin Dimitrov Oct 03 '12 at 09:46
  • have to notice that all datepickers in other views are OK except those in controllers with modelView thins is something with default option which is not supported when I create actions and views by myself – Minoucha Oct 03 '12 at 09:47
  • This post http://stackoverflow.com/questions/2356601/custom-datetime-model-binder-in-asp-net-mvc solved my problem(the comment of gdoron) – Minoucha Oct 03 '12 at 10:43
0

I had that problem, and solution was putting globalization information in web.config. like this: <globalization culture="sr-Latn-RS"/> Just check that you place that in <system.web>.

DarkoM
  • 335
  • 4
  • 5