New to Telerik UI for Blazor? Download free 30-day trial

Events

The events exposed for the Telerik TextArea for Blazor let you react to user actions and input. This article explains the events available in the Telerik TextArea.

OnChange

The OnChange event represents a user action - confirmation of the current value. It fires when the input loses focus.

The OnChange event does not prevent you from using two-way data binding.

Handle OnChange event

@TextAreaValue
<br />
<TelerikTextArea @bind-Value="@TextAreaValue"
                 OnChange="@OnChangeHandler">
</TelerikTextArea>

@code {
    public string TextAreaValue { get; set; }

    public void OnChangeHandler(object input)
    {
        Console.WriteLine($"The OnChange event fired with {input as string}");
    }
}

The event is an EventCallback. It can be synchronous and return void, or asynchronous and return async Task. Do not use async void.

ValueChanged

The ValueChanged event fires upon every change (for example, keystroke) in the input. When using the ValueChanged event you can not use two-way data binding, because the @bind-Value internally fires this event.

Handle ValueChanged event

@TextAreaValue
<br />
<TelerikTextArea Value="@TextAreaValue"
                 ValueChanged="@ValueChangedHandler">
</TelerikTextArea>

@code {
    public string TextAreaValue { get; set; }

    public void ValueChangedHandler(string input)
    {
        // you have to update the model manually because handling the ValueChanged event does not let you use @bind-Value
        TextAreaValue = input;
        Console.WriteLine($"The ValueChange event fired with {input}");
    }
}

The event is an EventCallback. It can be synchronous and return void, or asynchronous and return async Task. Do not use async void.

OnBlur

The OnBlur event fires when the component loses focus.

Handle the OnBlur event

@* You do not have to use OnChange to react to loss of focus *@

<TelerikTextArea @bind-Value="@TheValue"
                 OnBlur="OnBlurHandler">

</TelerikTextArea>
@code{
    async Task OnBlurHandler()
    {
        Console.WriteLine($"BLUR fired, current value is {TheValue}.");
    }

    string TheValue { get; set; }
}

See Also

In this article