blazor-devexpress-dot-blazor-dot-dxdateedit-1-cd544eb2.md
Fires when a user is changing a date in the Date Edit. Use this event to validate/cancel the newly selected date.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
[Parameter]
public Action<ParameterValueChangingEventArgs<T>> DateChanging { get; set; }
The DateChanging event's data class is ParameterValueChangingEventArgs<T>. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| NewValue | Gets or sets the new value being assigned to the parameter. |
| OldValue | Gets the current parameter value. |
The DateChanging event fires before a new date is applied to the editor (before the DateChanged event). You can use this event to validate/cancel user input.
The following code prevents weekend day selection. If a user tries to select Saturday or Sunday, the Date Edit’s value remains unchanged.
<DxDateEdit @bind-Date="@CurrentDate"
DateChanging="@OnDateChanging" />
@code {
DateTime CurrentDate { get; set; } = DateTime.Today;
void OnDateChanging(ParameterValueChangingEventArgs<DateTime> e) {
if (e.NewValue.DayOfWeek == DayOfWeek.Saturday ||
e.NewValue.DayOfWeek == DayOfWeek.Sunday) {
e.NewValue = e.OldValue;
}
}
}
Note
The Date Edit also supports masks that allow you to restrict user input to valid patterns.
See Also