Back to Devexpress

DxDateEdit<T>.DateChanging Event

blazor-devexpress-dot-blazor-dot-dxdateedit-1-cd544eb2.md

latest2.1 KB
Original Source

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

csharp
[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:

PropertyDescription
NewValueGets or sets the new value being assigned to the parameter.
OldValueGets 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.

razor
<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

DxDateEdit<T> Class

DxDateEdit<T> Members

DevExpress.Blazor Namespace