TimePicker HtmlHelper Overview

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

The TimePicker enables users to select time values from a predefined list or enter new ones.

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 TimePicker.

        <%: Html.Kendo().TimePicker()
            .Name("timepicker") // The name of the TimePicker is mandatory. It specifies the "id" attribute of the TimePicker.
            .Min(new DateTime(2010, 1, 1, 10, 0, 0)) // Set the min time of the TimePicker.
            .Max(new DateTime(2010, 1, 1, 20, 0, 0)) // Set the min date of the TimePicker.
            .Value(DateTime.Now) // Set the value of the TimePicker.
        %>
    
        @(Html.Kendo().TimePicker()
            .Name("timepicker") // The name of the TimePicker is mandatory. It specifies the "id" attribute of the TimePicker.
            .Min(new DateTime(2010, 1, 1, 10, 0, 0)) // Set the min time of the TimePicker.
            .Max(new DateTime(2010, 1, 1, 20, 0, 0)) // Set the min date of the TimePicker.
            .Value(DateTime.Now) // Set the value of the TimePicker.
        )
    

Events

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

Handling by Handler Name

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

    <%: Html.Kendo().TimePicker()
            .Name("timepicker")
            .Events(e => e
                .Open("timepicker_open")
                .Close("timepicker_close")
                .Change("timepicker_change")
            )
    %>
    <script>
        function timepicker_open() {
            // Handle the open event.
        }

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

        function timepicker_change() {
            // Handle the change event.
        }
    </script>
    @(Html.Kendo().TimePicker()
            .Name("timepicker")
            .Events(e => e
                .Open("timepicker_open")
                .Close("timepicker_close")
                .Change("timepicker_change")
            )
    )
    <script>
        function timepicker_open() {
            // Handle the open event.
        }

        function timepicker_close() {
            // Handle the close event
        }

        function timepicker_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().TimePicker() .Name("timepicker") .Events(e => e .Open(@ function() { // Handle the open event inline. } ) .Change(@ function() { // Handle the change event inline. } ) ) )

Referencing Existing Instances

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

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

See Also

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