[RESOLVED]Disable future date in Ajax CalendarExtender

Dear all,

i am using Ajax Control toolkit version 4.1. and i need to restrict user from entering future date. also in my web app user can enter date manul in textbox associated with Ajax Calendar extender control. any demo any suggestion. i need it urgently.


Calender1.EndDate =DateTime.Now.Date; // here you enter your future date

Or you can use this for furture end date limit

Calender1.EndDate = DateTime.Now.AddDays(90);;

Sorry dear EndDate  property is not available to me. i am using ‘CalendarExtender’ from Ajax toolkit

hey search this property on internet its work fine 

yourAjaxCalenderID.EndDate =DateTime.Now.Date

Download the demo program from given link


Program name is =CalenerDateLimit


thanks for your demo. its good but when i plug it into my app it does not work and also i cannot restrict date if user enter date manally in textbox. might be because of difference in minor version of Ajax toolkit that i am using


Please refer to the code as follow:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Calendar_limit.aspx.cs" Inherits="test7" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <script type="text/javascript">
                function checkDate(sender, args) {
            if (sender._selectedDate < new Date()) {
                alert("You cannot select a day earlier than today!");
                sender._selectedDate = new Date();
                // set the date back to the current date


    <form id="form1" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Date"/>
    <asp:CalendarExtender ID="CalendarExtender1" BehaviorID="CalendarExtender1" runat="server" TargetControlID="TextBox1" PopupButtonID="Button1" OnClientDateSelectionChanged="checkDate">
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    <asp:Button ID="Button2" runat="server" Text="test"/>
    <asp:CalendarExtender ID="CalendarExtender2" BehaviorID="CalendarExtender2" Format="dd/M/yy" runat="server" TargetControlID="TextBox2" PopupButtonID="Button2">

Try this


Calendar1_DayRender(object sender,DayRenderEventArgs
DateTime.Today){ e.Day.IsSelectable=

You can follow this link to achieve it:


refer this link it’s have a good example that may help you


nice then you have to use Compare Validator Expression with my provide demo

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="TextBox1"

ErrorMessage="CompareValidator" Operator="GreaterThanEqual" Type="Date"></asp:CompareValidator>

And Try to put this on page_load eventprotected void Page_Load(object sender, EventArgs e)

CompareValidator1.ValueToCompare = DateTime.Now.ToShortDateString();


Leave a Reply