The DatePicker control represents a text-box control with the ability to parse and select dates from a popup calendar.
Use the DatePicker.Value property to get or set the control's value.
The DatePicker control exposes a set of properties, allowing full control over user input. You can specify the format in which the input is expected by setting the CustomDateFormat property. By using MinDate and MaxDate properties you can limit the input to a specified date range and by setting the AllowEmptyInput property you can define whether or not empty string values are considered valid for the control.
Adjust the interaction with the control by setting the SubmitOnEnter and DatePartSelect properties according to your needs.
The control offers a built-in functionality for parsing incomplete user input which can be enabled by setting the AutoComplete property.
The position of the popup calendar can be adjusted by using the PopupAlignRight and PopupAlignTop properties.
The following events are exposed by the DatePicker class.
Event | Event arguments | Description |
---|---|---|
ValueChangedEventArgs<Nullable<DateTime>> | Raised when the control's value has changed. |
You can access the control on the client side by its ClientID.
JavaScript
![]() |
---|
var datePicker = $find("DatePicker1"); |
Use the get_value and set_value methods to get or set the control's value.
JavaScript
![]() |
---|
datePicker.set_value(new Date(2010,0,1)); |
Handle the stateChanged and/or valueInvalid events to apply special processing in case of invalid user input, e.g. change the CSS class of the control's date input.
JavaScript
![]() |
---|
function onStateChanged(sender, args) |
The following client-side event are exposed by the DatePicker class.
Event | Event arguments | Script property | Description |
---|---|---|---|
Raised when a control value has changed. | |||
Raised when the date input is invalid. | |||
Raised when the validation state of the control changes. | |||
- | Raised just after the control has finished loading and is ready for interaction. | ||
Raised when the control's popup is opened. | |||
Raised when the control's popup is closed. | |||
Raised when the control's popup is about to be opened. | |||
Raised when the control's popup is about to be closed. |