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

ValueChanged example does not work

2 Answers 42 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Iron
Veteran
Iron
Bob asked on 30 Sep 2020, 07:42 PM

I am following the example for the ValueChanged event with setting an initial value and it does not work.

I get the error that ValueExpression is required.  I try putting that in, but now when I click on the numeric textbox, 

Below is the code in your documentation for the example

from the handler: @result
<br />
from model: @theTbValue
<br />
 
<TelerikNumericTextBox Value="@theTbValue" ValueChanged="@( (decimal v) => MyValueChangeHandler(v) )"></TelerikNumericTextBox>
 
@code {
    string result;
 
    decimal theTbValue { get; set; } = 1.2345m;
 
    private void MyValueChangeHandler(decimal theUserInput)
    {
        result = string.Format("The user entered: {0}", theUserInput);
 
        //you have to update the model manually because handling the ValueChanged event does not let you use @bind-Value
        theTbValue = theUserInput;
    }
}

2 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 01 Oct 2020, 09:32 AM

Hello Bob,

I just tried this on a new project with 2.17.0 and it works fine for me. The error about a value expression being required is something that comes from the framework and happens when you nest the component in forms, and you can read more about it here: https://docs.telerik.com/blazor-ui/knowledge-base/requires-valueexpression

 

Regards,
Marin Bratanov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Bob
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 01 Oct 2020, 09:14 PM

Got it, I am in an EditForm.  

Thanks for the info.

Also, thanks for all the quick responses to my questions.

Tags
NumericTextBox
Asked by
Bob
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Marin Bratanov
Telerik team
Bob
Top achievements
Rank 1
Iron
Veteran
Iron
Share this question
or