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

What is the best way to post data back. I am doing this now, is this good ?

2 Answers 53 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 15 Mar 2013, 06:35 PM
Here is how my code looks on a MVC app. 

<body>
    @Html.Kendo().Calendar().Name("calendarstart").Value(DateTime.Now)
    <button id="save">Set date</button>
    <script>
        $(document).ready(function () {
            $("#save").click(function () {
                var startDate = $("#calendarstart").data("kendoCalendar");
                $.post("/Home/Index", { StartDate: startDate.value() });
            });
        });
    </script>
</body>

The issue i see is that their is no tight binding like what you have on MVC view model binding. 

Jay

2 Answers, 1 is accepted

Sort by
0
Jay
Top achievements
Rank 1
answered on 16 Mar 2013, 07:50 PM
So do i have to go to this much trouble to pass data back to the server ? . Create a Hidden filed, then use JS to fill that value ??

Jay


<body>
    @using (Html.BeginForm("Index", "Home", FormMethod.Post))
    {
        @Html.HiddenFor(m => m.Date)
 
        @(Html.Kendo().Calendar()
                  .Name("calendar")
                  .Value(DateTime.Now)
                  )
        <button name="button" value="save">Save Date</button>
    }
 
    <script>
        $(document).ready(function () {
            var calendar = $("#calendar").data("kendoCalendar");
            calendar.bind("change", function (e) {
                $("#Date").val(this.value());
            });
        });
    </script>
</body>
0
Petur Subev
Telerik team
answered on 19 Mar 2013, 03:30 PM
Hello Jay,

As I replied in the other forum thread that you opened - this is the preffered way to do it. The calendar is not intended to be submitted to the server - so consider using the DatePicker widgets.

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
General Discussions
Asked by
Jay
Top achievements
Rank 1
Answers by
Jay
Top achievements
Rank 1
Petur Subev
Telerik team
Share this question
or