|
| 1 | +--- |
| 2 | +title: Overview |
| 3 | +page_title: Date Picker for Blazor Overview |
| 4 | +description: Overview of the Date Picker for Blazor |
| 5 | +slug: components/datepicker/overview |
| 6 | +tags: telerik,blazor,date,picker,datepicker,overview |
| 7 | +published: True |
| 8 | +position: 0 |
| 9 | +--- |
| 10 | + |
| 11 | +# Date Picker Overview |
| 12 | + |
| 13 | +The Date Picker component allows the user to choose a date from a visual list ([calendar]({%slug components/calendar/overview%})) or to type it into a [date input]({%slug components/dateinput/overview%}) that can accept only dates. You can control the format shown in the input, the min and max date the user can select, and dates the user cannot select. |
| 14 | + |
| 15 | +To use a Telerik Date Picker for Blazor: |
| 16 | + |
| 17 | +1. @[template](/_contentTemplates/common/js-interop-file.md#add-blazor-js-file-to-list) |
| 18 | + |
| 19 | +1. add the `TelerikDatePicker` tag |
| 20 | + |
| 21 | +>caption Basic date picker with its key features, and ValueChanged event handling |
| 22 | +
|
| 23 | +@[template](/_contentTemplates/common/issues-and-warnings.md#generic-component-event-issue) |
| 24 | + |
| 25 | +````CSHTML |
| 26 | +@using Telerik.Blazor.Components.DatePicker |
| 27 | +
|
| 28 | +<TelerikDatePicker Min="@Min" Max="@Max" ValueChanged="@ValueChanged"></TelerikDatePicker> |
| 29 | +
|
| 30 | +<br />The selected date is: @selectedDate?.ToShortDateString() |
| 31 | +
|
| 32 | +@functions { |
| 33 | + public DateTime Max = new DateTime(2050, 12, 31); |
| 34 | + public DateTime Min = new DateTime(1950, 1, 1); |
| 35 | + private DateTime? selectedDate; |
| 36 | +
|
| 37 | + protected void ValueChanged(DateTime newValue) |
| 38 | + { |
| 39 | + selectedDate = newValue; |
| 40 | + } |
| 41 | +} |
| 42 | +```` |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +The Date Picker is a generic component and takes its type from the value the developer provides. This is reflected in the way a reference is obtained. |
| 47 | + |
| 48 | +>caption Component namespace and reference |
| 49 | +
|
| 50 | +````CSHTML |
| 51 | +@using Telerik.Blazor.Components.DatePicker |
| 52 | +
|
| 53 | + <TelerikDatePicker ref="@theDatePicker" bind-Value-ValueChanged="@datePickerValue"></TelerikDateInput> |
| 54 | +
|
| 55 | + @functions { |
| 56 | + Telerik.Blazor.Components.DatePicker.TelerikDatePicker<DateTime> theDatePicker; |
| 57 | +
|
| 58 | + DateTime datePickerValue { get; set; } = DateTime.Now; |
| 59 | + } |
| 60 | +```` |
| 61 | + |
| 62 | +The Date Picker component exposes the following features: |
| 63 | + |
| 64 | +* `BottomView` - Defines the bottommost view in the popup calendar to which the user can navigate to. Defaults to `CalendarView.Month`. |
| 65 | +* `DisabledDates` - Specifies a list of dates that can not be selected. |
| 66 | +* `Enabled` - Specifies whether typing in the input is allowed. |
| 67 | +* `Height` - Defines the height of the DatePicker. Defaults to 28. |
| 68 | +* `Format` - Specifies the format of the DateInput of the DatePicker. Defaults to `yyyy-MM-dd`. |
| 69 | +* `Min` - Sets the minimum allowed date of the date picker. Defaults to 1 Jan 1900. |
| 70 | +* `Max` - Sets the maximum allowed date of the date picker. Defaults to 31 Dec 2099. |
| 71 | +* `PopupHeight` - Defines the height of the DatePicker's Popup. Defaults to 280; |
| 72 | +* `PopupWidth` - Defines the width of the DatePicker's Popup. Defaults to 320. |
| 73 | +* `Value` - The current value of the input. Can be used for binding. |
| 74 | +* `View` - Specifies the current view that will be displayed in the popup calendar. |
| 75 | +* `Width` - Defines the width of the DatePicker. Defaults to 280. |
| 76 | +* Validation - see the [Input Validation]({%slug common-features/input-validation%}) article. |
| 77 | + |
| 78 | +The date picker is, essentially, a [date input]({%slug components/dateinput/overview%}) and a [calendar]({%slug components/calendar/overview%}) and the properties it exposes are mapped to the corresponding properties of these two components. You can read more about their behavior in the respective components' documentation. |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +## See Also |
| 83 | + |
| 84 | + * [Live Demo: Date Picker](https://demos.telerik.com/blazor/datepicker/index) |
| 85 | + * [Input Validation]({%slug common-features/input-validation%}) |
0 commit comments