DateTimePicker HtmlHelper Overview

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

The DateTimePicker allows the user to select a value from a calendar, a time drop-down list, or through direct input.

Initializing the DateTimePicker

The following example demonstrates how to define the DateTimePicker by using the DateTimePicker HtmlHelper.

The DateTimePicker copies any styles and CSS classes from the input element to the wrapper element.

    @(Html.Kendo().DateTimePicker()
        .Name("dateTimePicker")
    )

Functionality and Features

Events

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

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

    @(Html.Kendo().DateTimePicker()
      .Name("datetimepicker")
      .Events(e => e
            .Open("datetimepicker_open")
            .Close("datetimepicker_close")
            .Change("datetimepicker_change")
      )
    )
    <script>
    function datetimepicker_open() {
        // Handle the open event.
    }

    function datetimepicker_close() {
        // Handle the close event.
    }

    function datetimepicker_change() {
        // Handle the change event.
    }
      </script>

Referencing Existing Instances

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

The following example demonstrates how to access an existing DateTimePicker instance.

  // Place this after your DateTimePicker for ASP.NET Core declaration.
  <script>
  $(function() {
  // The Name() of the DateTimePicker is used to get its client-side instance.
      var datetimepicker = $("#datetimepicker").data("kendoDateTimePicker");
  });
  </script>

See Also

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