chanan / BlazorStrap

Bootstrap 4 Components for Blazor Framework
https://blazorstrap.io
The Unlicense
910 stars 156 forks source link

How to trigger method call on BsInput user inputs? #569

Closed obriankevin11 closed 1 year ago

obriankevin11 commented 1 year ago

Hi,

How can I get the value be updated when user types text in the input? Because for now that method is called when user moves focus.

<BSInput InputType="InputType.Text" InputSize="Size.Small" ValidateOnInput="true" ValueChanged="@((string txt) => OnValueChanged(txt))" />

Thanks!

jbomhold3 commented 1 year ago

You were almost there doing this off memory so if it doesn't work let me know will do some more testing and provide a different solution.
<BSInput InputType="InputType.Text" InputSize="Size.Small" ValidateOnInput="true" ValueChanged="@((string txt) => OnValueChanged(txt))" value="value"/>

@code {
  private string value = String.Empty;
  private void OnValueChanged(string txt)
  {
      value=txt;
      YourCode
  }
}