How to disable future date in ajax calendarextender

Nalini picture Nalini · Jun 30, 2015 · Viewed 7.3k times · Source

I have an user control in AJAX for the date calendar and I want to disable the future dates in the Calendar. I have tried to do it by using the Maximum Value property but that doesn't disables the control.

Any suggestions or help?

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="usrCtrlDatePicker.ascx.cs" Inherits="UserControls_usrCtrlDatePicker" %>
<table cellspacing="0" cellpadding="0" border="0" style="height:18px;">
    <tr>
        <td style="text-align:center; vertical-align:middle; height:16px">
            <asp:TextBox ID="txtDateEntry" runat="server" Width="75px" MaxLength="1" style="text-align:justify"/>
            <img alt="" id="btnShowCalendar" runat="server" src="../images/calendar.gif" style="margin-left:-4px; margin-bottom:-3px; height:17px; width:17px;" />
            <ajax:MaskedEditExtender ID="meeDateEntry" runat="server"
                TargetControlID="txtDateEntry"
                Mask="99/99/9999"
                MessageValidatorTip="false"
                CultureName="en-US"
                OnFocusCssClass="MaskedEditFocus"
                OnInvalidCssClass="MaskedEditError"
                MaskType="Date"
                ErrorTooltipEnabled="false"   />
            <ajax:MaskedEditValidator ID="mevDateEntry"  runat="server" ControlExtender="meeDateEntry" ControlToValidate="txtDateEntry" Display="Dynamic" EmptyValueBlurredText="*" EmptyValueMessage="Date is required" InvalidValueBlurredMessage="*" InvalidValueMessage="Date is invalid" IsValidEmpty="false" MaximumValueBlurredMessage="sjdfhsdfh" MaximumValueMessage="Maximum Value Exceeded." TooltipMessage="" ValidationExpression="(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d" ValidationGroup="" />
             <ajax:CalendarExtender ID="ceDateEntry" runat="server"
                Format="MM/dd/yyyy" 
                TargetControlID="txtDateEntry" 
                PopupButtonID="btnShowCalendar" />
        </td>
    </tr>
</table>

Answer

ashokd picture ashokd · Jun 30, 2015

You can use OnClientDateSelectionChanged event. Refer this.