asp.netajaxcontroltoolkitmaskededitextender

Problem with MaskedEdit from Ajax Control Toolkit - different culture


I want to use maskededit to make the user to do the same as in the ajax control toolkit sample for maskededit, but I need to use another format, since dates at my client is displayed as dd-MM-yyyy. I also need to put a value in there to begin with, since the date is loaded from a db (once I get this code working, that is)

Look at this sample: http://www.asp.net/ajax/ajaxcontroltoolkit/samples/maskededit/maskededit.aspx

I need to do the same as in the textbox labeled "Enter Date (format: 99/99/9999): "

I downloaded the sample code and changed the format to "99-99-9999" in the relevant code:

But the sample date "12-12-1999" is not displayed in the textbox. Why not?

I cant figure out, what I am doing wrong. I also tried setting the cultureName to da-DK, but it did not chance anything. I also tried Chrome, Firefox and IE7, same behaviour...

How do I fix this?

<asp:TextBox ID="TextBox5" runat="server" Width="130px" MaxLength="1" style="text-align:justify" ValidationGroup="MKE">12-12-1999</asp:TextBox>
    <asp:ImageButton ID="ImgBntCalc" runat="server" ImageUrl="~/images/Calendar_scheduleHS.png" CausesValidation="False" />
    <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender5" runat="server"
        TargetControlID="TextBox5"
        Mask="99-99-9999"
        MessageValidatorTip="true"
        OnFocusCssClass="MaskedEditFocus"
        OnInvalidCssClass="MaskedEditError"
        MaskType="Date"
        DisplayMoney="Left"
        AcceptNegative="Left"
        ErrorTooltipEnabled="True" />
    <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator5" runat="server"
        ControlExtender="MaskedEditExtender5"
        ControlToValidate="TextBox5"
        EmptyValueMessage="Date is required"
        InvalidValueMessage="Date is invalid"
        Display="Dynamic"
        TooltipMessage="Input a date"
        EmptyValueBlurredText="*"
        InvalidValueBlurredMessage="*"
        ValidationGroup="MKE" />

Solution

  • I use ValidationExpression in MaskedEditValidator replace userDateFormat type Date dd/MM/yyy is very good. This is :

    ValidationExpression="(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([02468][048])|([13579][26]))))"
    

    And in MaskedEditExtender put MaskType="none".
    Validate ok.