我正在開發windows 7,vs 2010上的asp.net mvc3項目。我已經添加了jquery和jquery ui引用項目。asp.net mvc jquery ui datepicker綁定問題
我有一個表格將數據保存到數據庫。在我的表單中,我有一個用於顯示日期選擇器的綁定編輯器模板的文本框。
如果我在我的計算機上發佈項目(Windows 7 IIS 7),一切正常。 但是當我將發佈的項目上載到服務器(Windows 2003 IIS 6)時,日期選取器值不正確。
編輯模板
@model Nullable<System.DateTime>
@Html.TextBox( "",
Model.HasValue ? Model.Value.ToString("dd.MM.yyyy") :string.Empty,
new { data_datepicker = true, @class = "text-box " })
的格式日期選擇Javascript代碼
$(文件)。就緒(函數(){
$.datepicker.setDefaults($.datepicker.regional['tr']);
$.datepicker.setDefaults({
changeMonth: true,
changeYear: true,
dateFormat: "dd.mm.yy",
minDate: 0
});
$(":input[data-datepicker]").datepicker();
})
我的職務行爲是
public ActionResult Create(FormViewModel formModel)
{
}
FormViewModel包含名稱和日期屬性。我認爲Model binder不是綁定日期。由於名稱屬性字段爲true,所以日期屬性會出錯。
錯誤: 值'18 .07.2012' 是無效的結束日期]
你能發佈你收到的錯誤嗎?你也確定服務器安裝了jQuery(如果腳本是本地的)? – Maess 2012-07-17 17:06:07
Erro消息是[值'18 .07.2012'對EndDate無效。] jquery上傳成功。 – bayramucuncu 2012-07-17 17:12:07
如果您的計算機和服務器的區域設置不同,可能是日期格式問題。 – MrOBrian 2012-07-17 17:14:52