Is it possible to store data with the mask?

Given this markup:
                                        <SfMaskedTextBox Mask="(000) 000-0000" Placeholder="Lounge Phone" 
                                            FloatLabelType="@FloatLabelType.Always" @bind-Value="@thisUnit.loungePhone">
                                        </SfMaskedTextBox>
                                        <ValidationMessage For="@(() => thisUnit.loungePhone)" />

Entering, 1112223333 appears as (111) 222-3333 and is stored in the database as '111222333'.
Is it possible to have the it stored as it is displayed ... '(111) 222-3333' ?


1 Reply 1 reply marked as answer

JM Jeyanth Muthu Pratheeban Sankara Subramanian Syncfusion Team April 9, 2021 09:23 AM UTC

Hello Byron, 

Thanks for contacting Syncfusion support. 

We checked your query of obtaining masked value. We would like to know you that Masked Textbox value will not contain the masked characters by default. You can get the value of the MaskedTextbox with mask value with the help of GetMaskedValue() method. We have made sample for your convenience. Please find the sample in the below link. 


<SfMaskedTextBox @ref="@Instance" Mask="(000) 000-0000" Placeholder="Lounge Phone" 
                 FloatLabelType="@FloatLabelType.Always"> 
</SfMaskedTextBox> 
 
<p>Masked Value:</p><strong>@Value</strong> 
 
<Syncfusion.Blazor.Buttons.SfButton OnClick="OnClick" >Get Mask Value</Syncfusion.Blazor.Buttons.SfButton> 
 
@code { 
    public SfMaskedTextBox Instance { get; set; } 
    public string Value { get; set; } 
 
    public void OnClick() 
    { 
        this.Value = this.Instance.GetMaskedValue(); 
    } 
 } 
 

Screenshot        :
 
 
 

Kindly integrate the provided solution with your application and get back to us if you need any further assistance on this. 

Regards, 
Jeyanth. 


Marked as answer
Loader.
Up arrow icon