Textbox Control is not binding real-time.

I did a test using textbox, I found out that textbox binded variable is not being binded in real-time. Check on the screenshot.
Is this a bug?


Attachment: SfTextbox_error_8e0fa08e.zip

5 Replies 1 reply marked as answer

SN Sevvandhi Nagulan Syncfusion Team September 14, 2020 10:29 AM UTC

Hello J, 


Greetings from Syncfusion support. 

We would like to inform you that the variable bounded by two-way binding will be changed after the change event is triggered. Change event will occur after the lost focus control. We will update the current value to the model at that point. So, we suggest you use the keyboard event argument to update the value to the variable. Refer to the code below, 

@using Syncfusion.Blazor.Inputs; 
 
<SfTextBox @bind-Value="text" @onkeypress="KeyPressed"></SfTextBox> 
 
@code{ 
    private string text; 
 
    public void KeyPressed(KeyboardEventArgs e) 
    { 
        text = e.Key; 
        Console.WriteLine("Text is:" + text); 
    } 
} 


Regards, 
Sevvandhi N 


Marked as answer

J j September 14, 2020 01:32 PM UTC

Ah okay. But can I ask if that is some kind of a bug or that's how Blazor behaves?


SN Sevvandhi Nagulan Syncfusion Team September 15, 2020 10:27 AM UTC


Hi j, 


Thanks for the update. 

The recorded issue also occurred in native Blazor InputText. Since we provided SfTextBox with the strongly typed API support, SfTextbox has similar functionality to Native textbox. We have added the example below to demonstrate the functionalities of both the component. 

[Index.razor] 


EditForm Model="@exampleModel"> 
    <DataAnnotationsValidator /> 
    <ValidationSummary /> 
 
    <InputText id="name" @bind-Value="exampleModel.Name" @onkeypress="KeyPressed" /> 
 
    <button type="submit">Submit</button> 
</EditForm> 
 
<SfTextBox @bind-Value="text" @onkeypress="KeyPressed"></SfTextBox> 
 
@code{ 
    private string text; 
 
    public void KeyPressed(KeyboardEventArgs e) 
    { 
        text = e.Key; 
        Console.WriteLine("Text is:" + text); 
        Console.WriteLine("Text is:" + exampleModel.Name); 
    } 
 
    private ExampleModel exampleModel = new ExampleModel(); 
 
    public class ExampleModel 
    { 
        public string Name { get; set; } 
    } 
 
} 



Please find the sample below. 



Kindly check the above sample and get back to us if you need further assistance. 


Regards, 
Sevvandhi N 



J j September 15, 2020 12:49 PM UTC

Okay, thank you.


SN Sevvandhi Nagulan Syncfusion Team September 16, 2020 05:16 AM UTC


Hi j, 


Thanks for the update. Please let us know if you need any other further assistance. 


Regards, 
Sevvandhi N 


Loader.
Up arrow icon