DateInput HtmlHelper Overview

The Telerik UI DateInput HtmlHelper for ASP.NET MVC is a server-side wrapper for the Kendo UI DateInput widget.

The DateInput represents an input field that recognizes and formats scheduling values such as dates.

Basic Configuration

  1. Make sure you followed all the steps from the introductory article on Telerik UI for ASP.NET MVC.
  2. Create a new action method which renders the view.

    public ActionResult Index() { return View(); }

  3. Add a DateInput.

        <%: Html.Kendo().DateInput()
            .Name("dateinput") // The name of the DateInput is mandatory. It specifies the "id" attribute of the DateInput.
            .Value(DateTime.Today) // Set the value of the DateInput.
        %>
    
        @(Html.Kendo().DateInput()
            .Name("dateinput") // The name of the DateInput is mandatory. It specifies the "id" attribute of the DateInput.
            .Value(DateTime.Today) // Set the value of the DateInput.
        )
    

Events

You can subscribe to all DateInput events. For a complete example on basic DateInput events, refer to the demo on using the events of the DateInput.

Handling by Handler Name

The following example demonstrates how to subscribe to events by a handler name.

    <%: Html.Kendo().DateInput()
        .Name("dateinput")
        .Events(e => e
            .Change("dateInput_change")
        )
    %>
    <script>
        function dateInput_change() {
            // Handle the change event.
        }
    </script>
    @(Html.Kendo().DateInput()
        .Name("dateinput")
        .Events(e => e
            .Change("dateInput_change")
        )
    )
    <script>
        function dateInput_change() {
            // Handle the change event.
        }
    </script>

Handling by Template Delegate

The following example demonstrates how to subscribe to events by a template delegate.

    @(Html.Kendo().DateInput()
      .Name("dateinput")
      .Events(e => e
          .Change(@<text>
            function() {
                // Handle the change event inline.
            }
            </text>)
      )
    )

Referencing Existing Instances

To reference an existing DateInput instance, use the jQuery.data() configuration option. Once a reference is established, use the DateInput client-side API to control its behavior.

// Place the following after the DateInput for ASP.NET MVC declaration.
<script>
    $(function() {
        // The Name() of the DateInput is used to get its client-side instance.
        var dateInput = $("#dateinput").data("kendoDateInput");
    });
</script>

See Also

In this article
Not finding the help you need? Improve this article