Html.Kendo().DatePickerFor does not functioning

2 posts, 0 answers
  1. Mehmet Fatih
    Mehmet Fatih  avatar
    1 posts
    Member since:
    Feb 2013

    Posted 20 Jan Link to this post

    Hi There;

    My code is as follows:

     

        public class Kisi
        {

            [Display(Name="date1")]
            public DateTime date1{ get; set; }

            [Display(Name = "date2")]
            public DateTime date2 { get; set; }

            [Display(Name = "date3")]
            public DateTime date3{ get; set; }

        }

    here is my view:

    //most parts ommited for brevity
    @model LojmanMVC.Domain.Kisi

    @{
        ViewBag.Title = "KisiOlustur2";
    }


    <h2>KisiOlustur2</h2>

    @using (Html.BeginForm()) {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)

        <fieldset>

            <!-- date1-->
            <div>
                <div class="editor-label">
                    <label>date1? </label>
                </div>
                <div class="editor-field">
                    

                    @(Html.Kendo().DatePickerFor(m=>m.date1)
                    .Name("dtpickerMemuriyetBaslama")
                    .Min(new DateTime(1900, 1, 1))
                    .Max(new DateTime(2099, 12, 31))
                    .Value(DateTime.Today)
                   
                     )

                    <br />

                    <!-- Html.ValidationMessageFor(model => model.MemuriyetBaslamaTarihi)-->
                </div>
            </div>


            <div id="tey" style="display:none">
                <div class="editor-label">
                    @Html.LabelFor(model => model.date2)
                </div>
                <div class="editor-field">
                    @(Html.Kendo().DatePickerFor(m=>m.date2)
                    .Name("dtAskerlikBaslama")
                    .Min(new DateTime(1900, 1, 1))
                    .Max(new DateTime(2099, 12, 31))
                    .Value(DateTime.Today)

                    )


                    @Html.ValidationMessageFor(model => model.AskerlikBaslangicTarihi)
                </div>
            </div>


            <div id="hey" style="display:none">
                <div class="editor-label">
                    @Html.LabelFor(model => model.date3)
                </div>
                <div class="editor-field">
                    @(Html.Kendo().DatePickerFor(m=>m.AskerlikBitisTarihi)
                    .Name("dtAskerlikBitis")
                    .Min(new DateTime(1900, 1, 1))
                    .Max(new DateTime(2099, 12, 31))
                    .Value(DateTime.Today)

                    )



                </div>
            </div>

    Here is my _Layout.cshtml:

    <!DOCTYPE html>
    <html>
    <head>
        
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
        <title>@ViewBag.Title</title>

        <link href="/Content/Site.css" type="text/css" rel="stylesheet" />    
        <link href="/Scripts/jquery-ui.css" rel="stylesheet" />
        <link href="~/Scripts/MenuStyle.css" rel="stylesheet" />

        <link href="~/Scripts/jquery-ui.css" rel="stylesheet" />

        <link href="@Url.Content("~/Content/kendo/2016.1.112/kendo.common.min.css")" rel="stylesheet" type="text/css" />
        <link href="@Url.Content("~/Content/kendo/2016.1.112/kendo.mobile.all.min.css")" rel="stylesheet" type="text/css" />
        <link href="@Url.Content("~/Content/kendo/2016.1.112/kendo.dataviz.min.css")" rel="stylesheet" type="text/css" />
        <link href="@Url.Content("~/Content/kendo/2016.1.112/kendo.default.min.css")" rel="stylesheet" type="text/css" />
        <link href="@Url.Content("~/Content/kendo/2016.1.112/kendo.dataviz.default.min.css")" rel="stylesheet" type="text/css" />
        <script src="@Url.Content("~/Scripts/kendo/2016.1.112/jquery.min.js")"></script>
        <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
        <script src="/Scripts/jquery-ui-1.11.4.min.js"></script>
        <script src="~/Scripts/jquery-ui.js"></script>
        <script src="~/Scripts/jquery-ui.min.js"></script>
        <script src="@Url.Content("~/Scripts/kendo/2016.1.112/jszip.min.js")"></script>
        <script src="@Url.Content("~/Scripts/kendo/2016.1.112/kendo.all.min.js")"></script>
        <script src="@Url.Content("~/Scripts/kendo/2016.1.112/kendo.aspnetmvc.min.js")"></script>

        <script src="~/Scripts/kendo/2016.1.112/cultures/kendo.culture.tr-TR.min.js"></script>
        <script>
            kendo.culture("tr-TR");
        </script>
    </head>
    <body>
        <div id="header">
            <div class="title">Lojman Bilgi Sistemi</div>
        </div>
        <div id="categories">
            @{ Html.RenderAction("Menu", "Nav"); }
        </div>
        <div id="content">
            @RenderBody()
        </div>
    </body>
    </html>

    The problem is that model's date1 date2 and date3 is null even though I pick date. How can I solve it?

    Thanks in advance.

     

  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 22 Jan Link to this post

    Hello,

    I would suggest you check this troubleshooting documentation: In short, you need to ensure that the widgets are named the same way as model field.

    Regards,
    Georgi Krustev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
Back to Top