Live Chat Icon For mobile
Live Chat Icon

How can you read the current value of an input element in Blazor?

Platform: Blazor| Category : Data binding, Event handling

The value of an input element is updated in the wrapper with the change events of elements in Blazor. To get the current value for each character input, you must use the oninput event of the input element. This can be achieved by binding the oninput event (native event) using the @bind:event=oninput.

 @CurrentValue
 <input type="text" @bind="@CurrentValue" @oninput="@((e) => { CurrentValue=(string)e.Value;})" />
  
 @code {
     private string CurrentValue {get;set;} = "blazor";
 } 

Refer to this StackOverflow link for more information.

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.