This is a migrated thread and some comments may be shown as answers.

Execute Method only on Enter for Text Box.

1 Answer 1912 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Luke
Top achievements
Rank 1
Luke asked on 22 May 2020, 01:14 PM

I want to be able to use either the enter key, or a button to search and I cant figure out a way to only call the search method on enter when using OnChange().

<div class="form-group">
<TelerikTextBox Id="look-up-value" @bind-Value="LookUpValue" Class="form-control" OnChange="(async () => {  await LookUpShipment(); })"></TelerikTextBox>
</div>
<TelerikButton Class="btn" Primary="true" OnClick="LookUpShipment">@TranslationService[Label.Search]</TelerikButton>

1 Answer, 1 is accepted

Sort by
1
Accepted
Svetoslav Dimitrov
Telerik team
answered on 25 May 2020, 06:31 AM

Hello Luke,

To use such behavior, clicking Enter key or button, you can attach event handlers to capture the DOM events. There is an knowledge base article related to this (link: https://docs.telerik.com/blazor-ui/knowledge-base/inputs-handle-keyboard-events). By going this approach you would not need to use the OnChange event.

Regards,
Svetoslav Dimitrov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
TextBox
Asked by
Luke
Top achievements
Rank 1
Answers by
Svetoslav Dimitrov
Telerik team
Share this question
or