New to Telerik UI for ASP.NET MVCStart a free 30-day trial

ASP.NET MVC DateTimePicker Overview

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.

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

Basic Configuration

The DateTimePicker configuration options are passed as attributes.

Razor
    @(Html.Kendo().DateTimePicker()
        .Name("end")
        .Value(DateTime.Today)
        .Min(DateTime.Today)
    )

The ParseFormats option is of type string[] and can be assigned either by a ViewBag property or by a property of the model.

Razor
    @(Html.Kendo().DateTimePicker()
        .Name("datetimepicker")
        .ParseFormats(new string[] { "MMMM yyyy", "MMMM" })
    )

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.

Razor
    @(Html.Kendo().DateTimePickerFor(m=>m.MyDateTimeProperty))

Functionality and Features

FeatureDescription
Disabled datesThe DateTimePicker allows you to disable specific days that shouldn't be selected by the end user, such as weekends and national holidays.
Component TypeThe DateTimePicker allows you to choose between two rendering options: standard and modern appearance.
Selected datesThe DateTimePicker allows you to render a pre-selected date and also define the minimum and maximum dates it displays.
Start view and navigation depthThe DateTimePicker enables you to set the rendered initial view and define the navigation depth of the views.
IntervalYou can configure the interval between the time values.
Floating LabelsYou can explicitly set a floating label which floats above the field and remains visible.
ValidationThe 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 formattingThe DateTimePicker allows you to define its date and time formatting.
Calendar typesBy default, the DatePicker works with Date objects which support only the Gregorian calendar.
Week number columnThe DateTimePicker provides options for rendering a column which displays the number of the weeks within the current Month view.
TemplatesThe DateTimePicker provides options for using and customizing its templates.
GlobalizationThe DateTimePicker comes with globalization support that allows you to use the component in apps all over the world.
AccessibilityThe DateRangePicker is accessible for screen readers, supports WAI-ARIA attributes, and delivers keyboard shortcuts for faster navigation.
Automatic CorrectionYou can configure whether the component will autocorrect the user's input when the Min and Max values are set.

Next Steps

See Also