Take the 2-minute tour ×

I've read through the Masked Edit and Phone Number control at asp.net and browsed for a while on this subject but haven't found an answer as to why this behavior is occurring.
I have the following MaskedEditExtender defined for use with phone numbers. I would like the mask to display prior to entering information into the textbox and remain both while making the entry and also after a valid entry.

<ajax:MaskedEditExtender ID="mee1" runat="server" Mask="999-999-9999" 
 AcceptNegative="None" MessageValidatorTip="true" TargetControlID="tbBox"
 MaskType="Number" ClearMaskOnLostFocus="false" ClearTextOnInvalid="false">

I believed a simple definition like the above would work, but the behavior of the form is erratic. The mask is visible prior to entering a value (when the textbox is empty) but while entering the mask disappears. Also, after the entry is made, the mask is no longer visible unless I click out of the textbox and then back into it. Once I get the mask to reappear with the entry, it seems to remain.

Is this control broken or am I missing something basic?

Thanks much for any help!

share|improve this question
I have found out (through selectively commenting out code) that it is related to a PreRender method on the TargetControlID textbox. The method adjusts the width of the textbox based upon input through applying a style via TextBox.Attributes.Add(). This still doesn't explain why this is causing problems with the mask. –  McArthey Apr 2 '12 at 17:01

1 Answer 1

up vote 0 down vote accepted

I hope this helps someone else. This issue was caused by a single statement in a PreRender method.

tbBox.MaxLength = <some integer>;

Apparently by changing this simple value as a property of the textbox caused all sorts of strangeness.
If anyone has an idea of why this is causing the failure I'd love to hear it. Thanks!

share|improve this answer

Your Answer


