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

RadMaskedTextBox formatting phone numbers incorrectly.

1 Answer 527 Views
Input
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 08 Nov 2010, 05:40 PM
I am using the RadMaskedTextBox controls for several phone number entries on a web form. I used the Smart tag to set up the mask I wanted to use and used declaritive binding in the page markup, like this:

<telerik:RadMaskedTextBox ID="txtPhone" runat="server" Mask="(###)###-####" Text='<%# DataBinder.Eval( Container, "DataItem.Phone" ) %>'
    TabIndex="6" EmptyMessage="-- Enter Phone Number --" HideOnBlur="true" ZeroPadNumericRanges="true" DisplayMask="(###)###-####">
</telerik:RadMaskedTextBox>

However, when the value from the data store is bound to the control, the output is displaying incorrectly. For instance, if the phone number in the data store is, "1112223333", then I would expect the masked display to appear as, "(111) 222-3333", but what is shown instead is, "(111) ___-222_".

Has anyone else seen this or found a work-around?

Thanks in advance,

Jon 

1 Answer, 1 is accepted

Sort by
0
Jon
Top achievements
Rank 1
answered on 09 Nov 2010, 09:09 PM
Update:

This issue was caused by bad data. In some cases, the phone number data contained formatting characters. In the example for this issue, the phone number was formatted as, "111-222-3333". The RadMaskedTextBox properly inserted the area code, but when it encountered the first dash("-"), it skipped the exchange portion of the mask and put the exchange value (222) in the first three digits of the number and ignored the (invalid) final dash and numbers, ("-3333").

Jon
Tags
Input
Asked by
Jon
Top achievements
Rank 1
Answers by
Jon
Top achievements
Rank 1
Share this question
or