Masked Input not Updating on first render

SfMaskedTextBox, how to load values on initialized, wont update the UI, but if I use a SfTextBox instead, it does.

All this running in the following way, I have a blazor page, and in this page I reference a razor component, which has all the sf components of the form.


1 Reply

SN Sevvandhi Nagulan Syncfusion Team May 22, 2020 08:43 AM UTC

Hi Raul, 


Greetings from Syncfusion support. 


You can load the values using the example code below as well as change the value at a time.Kindly refer the below code, 


<SfMaskedTextBox  Mask="00000" @bind-Value=@MaskValue></SfMaskedTextBox> 
 
@code { 
    public string MaskValue { get; set; } = "12345"; 
 
 
    protected override void OnInitialized() 
    { 
        MaskValue = "12345"; 
    } 
} 


Also, if you have updated the value in the OnAfterRender method, then assign the value to the variable as in the code example and call the StateHasChanged method to reflect the value to the component. 

<SfMaskedTextBox  Mask="00000" @bind-Value=@MaskValue></SfMaskedTextBox> 
 
@code { 
    public string MaskValue { get; set; } 
 
 
    protected override void OnAfterRender(bool firstRender) 
    { 
        if (firstRender) 
        { 
            MaskValue = "12345"; 
            StateHasChanged(); 
        } 
    } 
} 



Regards, 
Sevvandhi N 


Loader.
Up arrow icon