3

I have a ASP.Net MVC Razor page that uses a Kendo UI date-picker using the DatePickerFor Kendo MVC extension.

The culture info in my region requires the date format to be dd/MM/yyyy.

If I use dd/MM/yyyy then a date with a single digit for the day won't bind e.g. 1 August 2014.

However, if I use d/MM/yyyy then a date with two digits for the day won't bind e.g. 31 August 2014.

This appears to be a bug in Kendo UI. Does anybody know a work-around?

Update (more diagnosis): It appears the problem is the culture. 12 August 2014 binds because it is interpreting it at 8 December 2014.

Update (code samples, both give same result):

Using Format:

        <div class="form-group">
            @Html.LabelFor(m => m.To, new { @class = "col-lg-2 control-label" })
            <div class="col-lg-10">
                @Html.Kendo().DatePickerFor(m => m.To).Culture(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
                @Html.ValidationMessageFor(m => m.To)
            </div>
        </div>

Using Culture:

        <div class="form-group">
            @Html.LabelFor(m => m.To, new { @class = "col-lg-2 control-label" })
            <div class="col-lg-10">
                @Html.Kendo().DatePickerFor(m => m.To).Format(System.Globalization.CultureInfo.CurrentCulture.ToString())
                @Html.ValidationMessageFor(m => m.To)
            </div>
        </div>

Update (more info): Just to clarify, the binding issue is when submitting the form...binding works fine when the form is first loaded

TheMagnificent11
  • 1,424
  • 4
  • 19
  • 40

1 Answers1

0

Turns out the issue was a typo (copy-paste mistake). The form was using a GET instead of a POST.

TheMagnificent11
  • 1,424
  • 4
  • 19
  • 40