Back to Devexpress

DxMaskedInput<T>.ValueChanging Event

blazor-devexpress-dot-blazor-dot-dxmaskedinput-1-c42d370e.md

latest2.1 KB
Original Source

DxMaskedInput<T>.ValueChanging Event

Fires when the Masked Input’s value is being modified. Use this event to validate/cancel user input.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public Action<ParameterValueChangingEventArgs<T>> ValueChanging { get; set; }

Event Data

The ValueChanging 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 ValueChanging event fires before a new value is applied to the editor (before the ValueChanged event). You can use this event to validate/cancel user input.

The following code snippet applies the Currency mask and handles the ValueChanging event to limit the value range (0 - 1000). The current value is updated via two-way binding (@bind-Value).

razor
<DxMaskedInput @bind-Value="@Amount"
               ValueChanging="@OnValueChanging"
               Mask="@NumericMask.Currency">
</DxMaskedInput>

<div class="mt-2">
    <span>Current amount: @Amount.ToString("C")</span>
</div>

@code {
    decimal Amount { get; set; }

    private void OnValueChanging(ParameterValueChangingEventArgs<decimal> e) {
        if (e.NewValue < 0 || e.NewValue > 1000) {
            e.NewValue = e.OldValue;
        }
    }
}

See Also

DxMaskedInput<T> Class

DxMaskedInput<T> Members

DevExpress.Blazor Namespace