RadMaskedEditBox mask setting

1 Answer 55 Views
MaskedEditBox
Carl
Top achievements
Rank 1
Iron
Iron
Iron
Carl asked on 27 Aug 2024, 08:18 PM

I have a MaskedEditBox called mtbText bound to a string property like this:

mtbText.DataBindings.Add(nameof(mtbText.Value), customerSearch, nameof(customerSearch.Text), false, DataSourceUpdateMode.OnPropertyChanged);

        public string? Text
        {
            get => _text;
            set
            {
                if (_text != value)
                {
                    _text = value;
                    OnPropertyChanged(nameof(Text));
                }
            }
        }

Sometimes I need a specific mask like SSN or phone # and sometimes I don't.  The UI resets the properties on the single mask control depending on need. If I bind to a specific mask like this (say a SSN or phone #) it works fine. However sometimes I need a mask that will allow anything. I tried aaaaaaaaaa and a few other combination but these won't let me enter blank spaces.  If I set the MaskType to None it allow the spaces but doesn't bind to the property.

mtbText.Mask = string.IsNullOrEmpty(item.Mask) ? "aaaaaaaaaa" : item.Mask; 

mtbText.MaskType = MaskType.Standard;

mtbText.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;

What mask can I use that would allow me to enter something like 123 Main Street and still bind to the object property.

Thanks

Carl

 

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 28 Aug 2024, 09:11 AM

Hello Carl,

When the MaskType is set to None, the TextBoxProvider will be used. In this case, you can consider binding the Text property of the control instead.

this.radMaskedEditBox1.DataBindings.Add(nameof(radMaskedEditBox1.Text), this, nameof(CustomerSearch), false, DataSourceUpdateMode.OnPropertyChanged);

You can create additional logic that binds the Text property to a different property and use it when the MaskType is set to None. I hope that this approach will work for you.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Carl
Top achievements
Rank 1
Iron
Iron
Iron
commented on 28 Aug 2024, 01:48 PM

This worked great!

However, perhaps as a future enhancement, could the Value property also populate the Text property in such cases? This seems like a bit of a kludge.

Thanks

Carl

Nadya | Tech Support Engineer
Telerik team
commented on 02 Sep 2024, 06:45 AM

Hello, Carl,

Thank you for your feedback. We would consider this in future improvement of the control.

If you have any other questions do not hesitate to contact us.

Tags
MaskedEditBox
Asked by
Carl
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or