Here's one way that worked for me:
<asp:TextBox ID="txtCDate1" runat="server" Text="" Width="100" MaxLength="10"></asp:TextBox>
<ajaxToolkit:MaskedEditExtender runat="server" ID="MaskedEditExtender1" ClearMaskOnLostFocus="false"
MaskType="Date" Mask="9999/99/99" TargetControlID="txtCDate1" UserDateFormat="YearMonthDay">
</ajaxToolkit:MaskedEditExtender>
<ajaxToolkit:MaskedEditValidator runat="server" ID="MaskedEditValidator1" ControlToValidate="txtCDate1"
ControlExtender="MaskedEditExtender1" Display="dynamic" IsValidEmpty="False" InvalidValueMessage="*" />
<ajaxToolkit:CalendarExtender runat="server" ID="CalendarExtender1" TargetControlID="txtCDate1"
Format="yyyy-MM-dd">
</ajaxToolkit:CalendarExtender>
CalendarExtender
Format="yyyy-MM-dd"
For some reason in the masked edit it shows dashes instead of slashes so when setting the date, there's a mismatch which can prevent dates from being set and I believe part of the issue when changing months. So change the format to use dashes.
MaskedEditValidator
IsValidEmpty="False" InvalidValueMessage="*"
Without IsValidEmpty
set to false, I cannot change months more than one month if a date has not been set yet. Setting it to false makes it work... For InvalidValueMessage, put whatever error message.
MaskedEditExtender
MaskType="Date" UserDateFormat="YearMonthDay"
When you have a date set and you are trying to change months more than one month later/earlier, it seems like the masked edit extender prevents the months from changing. When you set the MaskType
to Date, it seems to "accept" it.
Also I had to set UserDateFormat
so that the error message set in MaskedEditValidator would not display everytime you change months or select a date. The error message would show just as you click but would hide once the change was made.
Conclusion
I'm not sure exactly what's causing this issue. From what I can tell from the "behaviour" the control seems to be setting a date into the mask which does not match causing the changing of months to "revert".
If anyone is interested and understands it better you can look at the source of CalendarExtender here. Switching of the months is done by the _switchMonth function.
Either way, ajax control toolkit has become even more buggy lately..