1

I have a master/detail scheme for editing an asp:GridView using an asp:DetailsView. One of my fields is for a phone number of type int64 (always 10 digits). I would like this field to always be displayed as (###)###-####. My issue is the first digit in the phone number is always truncated for my edit item field which I used a MaskedEditExtender to achieve the formatting.

Here is my EditItemTemplate for the details view:

<cc1:MaskedEditExtender TargetControlID="edtPROJ_Leader_Phone" Mask="(999)999-9999" runat="server" ClearMaskOnLostFocus="false" ClipboardEnabled="true" MaskType="Number" />
<asp:TextBox ID="edtPROJ_Leader_Phone" runat="server" Text='<%# Bind("PROJ_Leader_Phone") %>' ></asp:TextBox>

When my details view is displayed for editing, the text box displays(_23)456-7890 for the integer 1234567890. Also worth noting that if the property MaskType="Number" is removed, the textbox shows: (234)567-890_. I would of course have the textbox show (123)-546-67890 after binding.

Zach Skinner
  • 159
  • 3
  • 12

4 Answers4

2

Problem could be that you're not using "Escape Characters" for your "(", ")", and "-".

Might want to change your mask from

Mask="(999)999-9999"

to

Mask="\(999\)999\-9999"

According to the documentation, there is no "(", ")", or "-", so you may be telling it to do something unintended. From the section on masks...

/ - Date separator

: - Time separator

. - Decimal separator

, - Thousand separator

\ - Escape character

{ - Initial delimiter for repetition of masks

} - Final delimiter for repetition of masks

Examples

9999999 - Seven numeric characters

99/99 - Four numeric characters separated in the middle by a "/"

http://www.asp.net/ajaxlibrary/act_MaskedEdit.ashx

1

This issue appears to be a bug related to: http://www.codeplex.com/AjaxControlToolkit/WorkItem/View.aspx?WorkItemId=11819

Zach Skinner
  • 159
  • 3
  • 12
0

I had the same issue too, and :

  1. Doing despecialisation in the mask like :

        Mask="\(999\)999\-9999",
    
  2. With ClearMaskOnLostFocus set to true.

Solved the problem.

Thanks for all.

0

I had the same issue, and what solved it for me was changing the MaskedEditExtender's property
"ClearMaskOnLostFocus" to True.

Smur
  • 3,075
  • 7
  • 28
  • 46