Hello,
I have an issue regarding the posting of a DateTimePicker value to a controller. Code is as follows:
View:
1.@(Html.Kendo().DateTimePickerFor(model => model.FechaLimite)2. .Format("dd/MM/yyyy hh:mm tt") 3. .TimeFormat("hh:mm tt")4. .Value(DateTime.Now)5. .HtmlAttributes(new { @class = "form-control" }))Controller:
1.[HttpPost]2.[ValidateAntiForgeryToken]3.public ActionResult Create([Bind(Include = "FechaLimite")] TiqueteViewModel viewModel)4.{5. if (ModelState.IsValid)6. {7. }8.}There are other fields inside the viewModel which I have omitted for the sake of simplicity, but it's a really weird behavior, I'll explain:
- If I POST the form with the default value that's loaded into the DateTimePicker (DateTime.Now), it posts correctly, see screenshot "POSTDefaultValue".
- If I POST the form changing either the date or the time, it POSTS nothing, see screenshot "POSTChangeValue".
- If I remove the "Format" from the DateTimePicker, it always posts correctly, however, I need the user to see it in am/pm format, see screenshot "POSTWithoutFormat".
When the value is not POSTed, I get the error in screenshot "DateTimeError", like in case number 2.
So I'm guessing it has something to do with the format validation once the date is changed. I have set the same culture to both kendo on the client-side and on the server side using the guides you have available. Just in case, the culture I've set is "es-CR".
Any idea what could be causing this behavior ? If an example is needed I can isolate the issue and attach a project.
