DxDateEdit<T>.DateChanging Event
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
Declaration
[Parameter]
public Action<ParameterValueChangingEventArgs<T>> DateChanging { get; set; }
Event Data
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. |
Remarks
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.