ASP.NET MVC DateTimePicker Overview

Telerik UI for ASP.NET MVC Ninja image

The DateTimePicker is part of Telerik UI for ASP.NET MVC, a professional grade UI library with 110+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.

The Telerik UI DateTimePicker HtmlHelper for ASP.NET MVC 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.

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

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

Model Binding

The DateTimePicker component respects DataAnnotations when the DateTimePickerFor(m=>m.Property) method is used. Besides the [Required] attribute, the [DisplayFormat] and [Range] attributes are also supported. The Format configuration will be set to the provided DisplayFormat and the Min and Max configurations will be set based on the range provided.

    @(Html.Kendo().DateTimePickerFor(m=>m.MyDateTimeProperty))
    [Required]
    [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
    [Range(typeof(DateTime), minimum:"01/01/2023", maximum:"31/12/2023")]
    public DateTime MyDateTimeProperty{ get; set; }

Functionality and Features

Feature Description
Disabled dates The DateTimePicker allows you to disable specific days that shouldn't be selected by the end user, such as weekends and national holidays.
Selected dates The DateTimePicker allows you to render a pre-selected date and also define the minimum and maximum dates it displays.
Start view and navigation depth The DateTimePicker enables you to set the rendered initial view and define the navigation depth of the views.
Validation The DateTimePicker does not automatically update the typed text when the typed text is invalid. Such changes in the input value may lead to unexpected behavior.
Date and time formatting The DateTimePicker allows you to define its date and time formatting.
Calendar types By default, the DatePicker works with Date objects which support only the Gregorian calendar.
Week number column The DateTimePicker provides options for rendering a column which displays the number of the weeks within the current Month view.
Templates The DateTimePicker provides options for using and customizing its templates.
Globalization The DateTimePicker comes with globalization support that allows you to use the component in apps all over the world.
Accessibility The DateRangePicker is accessible for screen readers, supports WAI-ARIA attributes, and delivers keyboard shortcuts for faster navigation.

Next Steps

See Also

In this article