ValueChange

Dear support team,


I have read lots of posts, but I can't find a reasonable answer.


I am looking to bind a NumericTextbox to a property and get the value while the user is still typing, instead of when the control loses focus. This works perfectly in strings, but not in numbers.


is it possible?


Thanks in advance.

Regards.


5 Replies 1 reply marked as answer

MG Manuel Gonzales July 20, 2022 02:05 PM UTC

I was looking for this too (i'm using 19.xx.xx) and i found this link:

https://blazor.syncfusion.com/documentation/numeric-textbox/native-events#list-of-native-events-supported


so i used the keypress and made sure my tvalue was int or decimal.  works.




GW George Waters replied to Manuel Gonzales July 21, 2022 02:35 AM UTC

Hi Manuel,

Thanks for taking the time to reply.

I've thought about this solution using Regex but I wanted to know if Syncfusion has updated its control to accept this requirement.

Do you have a sample of how you did it?

Best regards.



MM Mohanraj Mathaiyan Syncfusion Team July 21, 2022 05:55 PM UTC

Hi George Waters,

We have validated your requirement and we suggest using OnInput event which will get triggered on every input from the user.


kindly refer the below snippet for your reference.

<SfNumericTextBox TValue="int?" OnInput= "KeyPressed"></SfNumericTextBox>

 

Value : @value

 

 

@code {

    int value;

    double val;

 

    public void KeyPressed(ChangeEventArgs args)

    {

 

        if(double.TryParse(args.Value.ToString(), out val))

        {

            value = int.Parse(args.Value.ToString());

        }

    }

}


If the above solution does not meet your requirements, can you please share more detailed information about your requirements? So, we will check and provide a prompt solution as soon as possible.


Regards,

Mohanraj M


Attachment: numbertextbox176315_a0972a3a.zip

Marked as answer

GW George Waters replied to Mohanraj Mathaiyan July 21, 2022 07:05 PM UTC

That's the exact solution for what I've been struggling last 2 days.

I'd buy you a beer.

Thanks Mohanraj !!!



SP Sureshkumar P Syncfusion Team July 22, 2022 05:45 AM UTC

George,


Thanks for your update.


Regards,

Sureshkumar P


Loader.
Up arrow icon