1

I'm trying to have a textbox function exactly like the third textbox down on this page: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/MaskedEdit/MaskedEdit.aspx. I'm trying to use a CalendarExtender control with a MaskedEditExtender, because I don't want the user to be able to enter anything except a valid date into the box. On my maskededitextender I have a mask of "99/99/9999" but it seems to only work when the date is actually 8 digits (e.g. 12/12/2000) and not when the date is 7 or 6 digits (e.g. 1/1/2000 or 1/14/2000). The mask screws up when the date is less than 8 digits. Here is my code:

<asp:TextBox runat="server" ID="txtDateAvailable" Width="150px" maxlength="50"></asp:TextBox>
<asp:CalendarExtender ID="calDateAvailable" runat="server" TargetControlID="txtDateAvailable" format="d" PopupPosition="Right"></asp:CalendarExtender>
<asp:MaskedEditExtender ID="mskDateAvailable" runat="server" targetcontrolid="txtDateAvailable" Mask="99/99/9999" clearmaskonlostfocus="false" MaskType="None"></asp:MaskedEditExtender>

If I could figure out how to get the date format of the CalendarExtender to MM/DD/YYYY instead of just M/D/YYYY that would fix it.

Industrial Themes
  • 557
  • 2
  • 9
  • 26

2 Answers2

4

There is a Format property of Calendar Control. Use that to set to

Format="MM/dd/yyyy"
gbs
  • 7,196
  • 5
  • 43
  • 69
  • hi what about on dd.MMM.yyyy format. what mask for maskededitextender. – Rob Apr 17 '13 at 01:29
  • 1
    @Rob try Mask="99.LLL.9999" http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/MaskedEdit/MaskedEdit.aspx – gbs Apr 17 '13 at 16:31
  • What about ddMMyy? I can paste it in, but it gets changed to MM/dd/yyyy. Still works, but I'd rather it didn't change. – Jooooosh Jul 06 '15 at 15:26
0

The syntax for it is as follows: Format="MM/dd/yyyy" and change it around as you wish, but you must ensure that the month is in uppercase otherwise it will return zeros i used -

<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1" 
    PopupButtonID="ImageButton1" Format="dd/MM/yy">
Salvatorelab
  • 11,614
  • 6
  • 53
  • 80
Floyd
  • 1