4

I am developing asp.net mvc3 project on windows 7, vs 2010. I have added jquery and jquery ui references to project.

I have a form that saves data to database. In my form I have a textbox which binded editor template for show date picker.

If I publish the project on my computer (windows 7 IIS 7) everything works correctly. But When I upload the published project to server (Windows 2003 IIS 6) the date picker value is not correct error occuring.

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 format datepicker

$(document).ready(function () {

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

$(":input[data-datepicker]").datepicker();

})

My POST action is

public ActionResult Create(FormViewModel formModel)
{

}

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

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

4
  • Can you post the error that you are getting? Also are you sure that the server has jQuery installed (if the scripts are local)? Commented Jul 17, 2012 at 17:06
  • Erro Message is [The value '18.07.2012' is not valid for EndDate.] Jquery are uploaded successful. Commented Jul 17, 2012 at 17:12
  • Could be a date format issue if the locale of your computer and the server are different. Commented Jul 17, 2012 at 17:14
  • My local is turkish regional settings, server was united states settings. But I setted the server turkish regional settings. (I updated post now) Commented Jul 17, 2012 at 17:18

3 Answers 3

1

I solved problem. The culture difference issue is my problem. I set the web configuration file. <globalization culture="tr-TR" />

Sign up to request clarification or add additional context in comments.

Comments

0

I'm surprised it works locally. I would think you need something like:

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

Comments

0

I had a similar situation in which my solution was working perfectly locally, but when deployed on Windows Server 2012 , the date field was setting to 01/01/0000 :00 00 00 upon form submission.

I added the globilization tag in my Web.Config such as

<globalization culture="en-US" />

and it works fine now.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.