Back to Devexpress

DxTextBox.TextChanging Event

blazor-devexpress-dot-blazor-dot-dxtextbox-acc8cf41.md

latest2.1 KB
Original Source

DxTextBox.TextChanging Event

Fires when a user is changing text in the editor. 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<string>> TextChanging { get; set; }

Event Data

The TextChanging event's data class is ParameterValueChangingEventArgs<String>. 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 TextChanging event fires before a new text is applied to the editor (before the TextChanged event). You can use this event to validate/cancel user input.

The following code snippet cancels digit input in the TextChanging event handler. The current text is updated via two-way binding (@bind-Text).

razor
<DxTextBox @bind-Text="@TextValue"
           TextChanging="@OnTextChanging"
           BindValueMode="BindValueMode.OnInput">
</DxTextBox>

<div class="mt-2">
    <span>Current text: @TextValue</span>
</div>

@code {
    string TextValue { get; set; }

    private void OnTextChanging(TextChangingEventArgs e) {
        if (e.NewText.Any(char.IsDigit)) {
            e.NewValue = e.OldValue;
        }
    }
}

Note

You can also use the Masked Input component to restrict user input to valid patterns.

See Also

DxTextBox Class

DxTextBox Members

DevExpress.Blazor Namespace