Pass (Send) jQuery DatePicker selected value to Controller in ASP.Net MVC

Last Reply on Apr 11, 2019 03:16 AM By dharmendr

Posted on Apr 10, 2019 04:24 PM

Hey everyone,

I have a datepicker and when I don't use datepicker I get the date value in my view but with it it just displays the format MM/dd/yyyy so I am wondering how can I get my datepicker to show the saved value when I load the view.

        [Display(Name = "Username")]
        public string UserName { get; set; }

            DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}",
            ApplyFormatInEditMode = true)]
        [Display(Name = "Birthday")]
        public DateTime Birthday { get; set; }

        [Display(Name = "Date Created")]
        public DateTime DateCreated { get; set; } 


        $(function () {
                dateFormat: "MM/dd/yy",
                changeYear: true,
                shownOn: "button"
            }).css("display", "inline-block")
                    icons: { primary: "ui-icon-calendar" },
                    label: "Select a Date",
                    text: false
                dateFormat: 'MM/dd/yyyy',
                timeFormat: 'hh:mm:ss',
                timeInput: true,
    <div class="col-md-10">
        @Html.EditorFor(model => model.Birthday, new { htmlAttributes = new { @class = "form-control datepicker" } })
        @Html.ValidationMessageFor(model => model.Birthday, "", new { @class = "text-danger" })


This question does not have replies that have been liked.