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.
@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 returnvoid
, or asynchronous and returnasync Task
. Do not useasync 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.
@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 returnvoid
, or asynchronous and returnasync Task
. Do not useasync void
.
OnBlur
The OnBlur
event fires when the component loses focus.
@* 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; }
}