views:

968

answers:

1

The MaskedEditExtender does a good job of enforcing the rules, but my users have trouble typing into its TextBox.

I want to select all the contents of my TextBox when it gains focus.

A regular JavaScript solution does not work.

onfocus="javascript:this.select();"

The MaskedEditExtender interferes.

How can I select all the contents of the TextBox when it gains focus?

<asp:TextBox
    ID="TextBoxPrice"
    runat="server" />
<ajaxToolkit:MaskedEditExtender
    ID="MaskedEditExtenderTextBoxPrice"
    runat="server"
    TargetControlID="TextBoxPrice"
    Mask="9,999.99"
    MaskType="Number"
    MessageValidatorTip="False"
    OnFocusCssClass="MaskedEditFocus"
    OnInvalidCssClass="MaskedEditError"
    InputDirection="RightToLeft"
    AcceptNegative="None"
    DisplayMoney="Left" />
<ajaxToolkit:MaskedEditValidator
    ID="MaskedEditValidatorTextBoxPrice"
    runat="server"
    ControlToValidate="TextBoxPrice"
    ControlExtender="MaskedEditExtenderTextBoxPrice"
    Display="Dynamic"
    IsValidEmpty="False"
    EmptyValueMessage="Price is required"
    InvalidValueMessage="Price is invalid"
    MinimumValue= "0.01"
    MinimumValueMessage="Price is too small"
    MaximumValue="9999.99" 
    MaximumValueMessage="Price is too large" />
+1  A: 

I am having this same problem. Does anyone have a solution?

Scott