Trouble with date

3 posts, 1 answers
  1. Shimon
    Shimon avatar
    18 posts
    Member since:
    Jul 2013

    Posted 27 Mar 2014 Link to this post

    Hi Telerik Team.

    I copy paste the Telerik code of "ScheldulerCustomEditor".

    I have the following error : "The field Start must be a date/ The field End must be a date".

    I search in the forum but I don't thing it's a trouble of culture.
    In FireBug, the right "cultures/" is loaded.
         var culture = Thread.CurrentThread.CurrentUICulture.ToString();
         var cultureServer = Thread.CurrentThread.CurrentCulture.ToString();
    give both "fr-FR" as a result.

    And i followed the Kendo Globalization tutorial
    var culture = System.Globalization.CultureInfo.CurrentCulture.ToString();
    <script src="@Url.Content("~/Scripts/kendo/2014.1.321/cultures/kendo.culture." + culture + ".min.js")"></script>

    I solved this trouble with Data annotation

    [Required(ErrorMessage = "Please select a End time")]
    [DateGreaterThan(OtherField = "Start")]
    public DateTime End
            return end;
            end = value.ToUniversalTime();

    But i have another error. It's display that "The isAllDay field is required".
  2. Shimon
    Shimon avatar
    18 posts
    Member since:
    Jul 2013

    Posted 27 Mar 2014 in reply to Shimon Link to this post

    I set the WebPageRenderingBase.Culture to the right culture.
    So for the DateTimePickerFor
    In the "en-US" culture i have time format like this : 3/27/2014 6:00 AM
    In the "fr-FR" culture i have time format like that :   27/03/2014 06:00

    In the editorTemplate, when i click on save nothing happend. I must click on IsAllDay checkBox to reach the controller.
    And when i click on IsAllDay the time format change : for instance in fr-FR : "27/03/2014"

  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Answer
    Alexander Popov
    Alexander Popov avatar
    1416 posts

    Posted 31 Mar 2014 Link to this post

    Hello Shimon,

    This happens because ASP.NET MVC renders all checkboxes with a required attribute, unless DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes is set to false in the Global.asax file. Another approach would be to replace the HTML helper with a simple input element: 
    <div data-container-for="isAllDay" class="k-edit-field">
        <input data-bind="checked: isAllDay" data-val="true" id="IsAllDay" name="IsAllDay" type="checkbox" />

    Alexander Popov

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

Back to Top