Change detection of form elements while typing

Hi Radzen Team,

I have a form where I need to show buttons if there are some changes. The issue is that it only detects the changes if I remove focus on that element by clicking somewhere else. So as an example, it is not going to trigger the change method while I am typing and changing the value of a text box. Is there any way to detect changes while typing?

Kind regards,

1 Like

You can use @oninput event. For example:

@oninput="@(args => SomeProperty = args.Value)"
3 Likes

Further more can I also add another tip to this thread.

If you do a separate getter/setter for the property that you bind to your radzen control, you can call functionality AND write a regular variable at the same time.

For example:

<RadzenTextBox ..... @oninput="@(args => SomeProperty = args.Value)" ..... />

then

@code {

  private string _internalSomeProperty;
  private string SomeProperty {
    get { return _internalSomeProperty; }
    set {
      _internalSomeProperty = value;
      SomeFunction(value);
    }
  }

  private void SomeFunction(string avalue) {
    // do something with avalue here
  }

That way you can also get advanced functionality, just by your control setting the value of your variable, without having to create different handlers, and all while reacting to instant changes.

2 Likes