MaskedEditExtender, dates and Globalization

3.4k Views Asked by At

I want to use the MaskedEditExtender to mask short dates. The problem is that I want to mask the field depending on the user language settings. This is working for a lot of cases, but for example for Latvian Culture (with format 9999.99.99. ) is not working.

<cc1:MaskedEditExtender  ID="MaskedEditExtender1" runat="server" AutoComplete="True" MaskType="Date" TargetControlID="myTextbox" ClearMaskOnLostFocus="True" 
   OnInvalidCssClass="myInvalidCss" OnFocusCssClass="myOnFocusClass" Mask="99/99/9999" >
</cc1:MaskedEditExtender>

Is there a simple way to set the Mask property with the user culture mask format? Am I missing something to do this easier?

1

There are 1 best solutions below

4
On BEST ANSWER

Not sure why the extender won't recognize Latvian culture, but try looking at the overrides provided, such as CultureDateFormat and CultureDecimalPlaceholder. More info at the AJAX Control Toolkit sample website.

EDIT: Response to OP's comments:

I have not idea if this works, but it looks like you can get the short date format for a culture from the CultureInfo class, like this.

string shortDateFormat = 
      System.Globalization.CultureInfo.DateTimeFormat.ShortDatePattern

Take a look here for examples.