DxTagBox<TData, TValue>.TagsChanging Event
Fires when a user is changing tags in the Tag Box. Use this event to validate/cancel user input or tag selection.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.2.dll
NuGet Package: DevExpress.Blazor
Declaration
[Parameter]
public Action<ParameterValueChangingEventArgs<IEnumerable<string>>> TagsChanging { get; set; }
Event Data
The TagsChanging event's data class is ParameterValueChangingEventArgs<IEnumerable<String>>. 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 TagsChanging event fires before new tags are applied to the component (before the TagsChanged event). You can use this event to validate/cancel user input or tag selection.
The following code prevents selection of more than three tags. If a user tries to select a fourth tag, the Tag Box’s value remains unchanged.
<DxTagBox Data="@Cities"
AllowCustomTags="true"
Tags="@Tags"
TagsChanged="@TagsChanged"
TagsChanging="@OnTagsChanging"
@bind-Values="@Values">
</DxTagBox>
@code {
IEnumerable<string> Tags = new List<string>() {
"London",
"New York"
};
IEnumerable<string> Cities = new List<string>() {
"London",
"Berlin",
"Paris",
"New York",
};
IEnumerable<string> Values;
void TagsChanged(IEnumerable<string> newTags) {
Tags = newTags;
}
void OnTagsChanging(ParameterValueChangingEventArgs<IEnumerable<string>> e) {
if (e.NewValue != null && e.NewValue.Count() > 3) {
e.NewValue = e.OldValue;
}
}
}