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

ValueChanged event with lambda

1 Answer 365 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Juan Angel
Top achievements
Rank 1
Veteran
Juan Angel asked on 08 Nov 2020, 10:41 AM

Documentation suggest a lamba expression in ValueChanged event because it's requiered by framewoek, but for me this sentences are equivalent:

from the handler: @result
<br />
from model: @theTbValue
<br />
 
<TelerikTextBox ValueChanged="@( (string s) => MyValueChangeHandler(s) )" Value="@theTbValue"></TelerikTextBox>
 
<TelerikTextBox ValueChanged="@MyValueChangeHandler" Value="@theTbValue"></TelerikTextBox>
 
@code {
    string result;
 
    public string theTbValue { get; set; } = "lorem ipsum";
 
    private void MyValueChangeHandler (string 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;
    }
}

 

1 Answer, 1 is accepted

Sort by
0
Kristian
Telerik team
answered on 11 Nov 2020, 04:41 PM

Hello Juan Angel,

The approach you are using is the correct one.

Using only lambdas was a limitation in the Blazor framework before but it seems they fixed it with one of the new releases.

I changed the documentation and it will go live with our next deploy.

Thanks for bringing this up and helping us to improve the documentation.

Regards,
Kristian
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
TextBox
Asked by
Juan Angel
Top achievements
Rank 1
Veteran
Answers by
Kristian
Telerik team
Share this question
or