Asp.net mvc jquery ui datepicker required problem

I am developing an asp.net mvc3 project on Windows 7, vs 2010. I have added jquery and jquery ui project links.

I have a form that stores data in a database. In my form, I have a text box that linked an editor template to select a date.

If I publish the project on my computer (Windows 7 IIS 7), everything will work correctly. But when I upload the published project to the server (Windows 2003 IIS 6), the date pick value is the wrong error.

Editor Template

@model Nullable<System.DateTime> @Html.TextBox( "", Model.HasValue ? Model.Value.ToString("dd.MM.yyyy") :string.Empty, new { data_datepicker = true, @class = "text-box " }) 

Javascript code for datepicker format

$ (document) .ready (function () {

 $.datepicker.setDefaults($.datepicker.regional['tr']); $.datepicker.setDefaults({ changeMonth: true, changeYear: true, dateFormat: "dd.mm.yy", minDate: 0 }); $(":input[data-datepicker]").datepicker(); 

})

Action of my post

 public ActionResult Create(FormViewModel formModel) { } 

FormViewModel contains name and date properties. I thiks Model binder does not bind date. because the name property field is true, the date property gets an error.

Error: The value "18.07.2012" is not valid for EndDate.]

+4
source share
3 answers

I solved the problem. The problem of difference in culture is my problem. I installed the network configuration file. <globalization culture="tr-TR" />

+1
source

I am surprised that it works locally. I think you need something like:

 $('.text-box').datepicker(); 
0
source

I had a similar situation where my solution worked perfectly locally, but when deployed to Windows Server 2012, the date field set the value 01/01/0000: 00 00 00 after the form was submitted.

I added the globilization tag to my Web.Config, for example

 <globalization culture="en-US" /> 

and now it works great.

0
source

All Articles