This is a migrated thread and some comments may be shown as answers.

Passing the select value back to Server

1 Answer 133 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 17 Mar 2013, 07:19 PM
So is this the only way to pass the value that has been selected back to the server ...seems like way too much glue code , I have to have a hidden field, then need to use JS to fill that field etc etc

Jay

<body>
    @using (Html.BeginForm("Index", "Home", FormMethod.Post))
    {
        @Html.HiddenFor(m => m.StartDate)
 
        @(Html.Kendo().Calendar()
                  .Name("calendarStart")
                  .Value(DateTime.Now)
              )
         
        @Html.HiddenFor(m => m.EndDate)
 
        @(Html.Kendo().Calendar()
                  .Name("calendarEnd")
                  .Value(DateTime.Now)
                  )
         
        <button name="button" value="save">Save Date</button>
    }
 
    <script>
        $(document).ready(function () {
 
            var calendarStart = $("#calendarStart").data("kendoCalendar");
            $("#StartDate").val((moment(calendarStart.value()).format("YYYY-MM-DD")));
 
            calendarStart.bind("change", function (e) {
                $("#StartDate").val((moment(this.value())).format("YYYY-MM-DD"));
             
            });
 
            var calendarEnd = $("#calendarStart").data("kendoCalendar");
            $("#EndDate").val((moment(calendarEnd.value()).format("YYYY-MM-DD")));
 
            calendarEnd.bind("change", function (e) {
                $("#EndDate").val((moment(this.value())).format("YYYY-MM-DD"));
            });
 
        });
    </script>
</body>

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 19 Mar 2013, 09:41 AM
Hello Jay,

If you want to submit the value to the server consider using the DatePicker widget other way you will have to go this way and create the hidden field which to be submitted.

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Calendar
Asked by
Jay
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or