In this article I will explain with an example, how to disable future date selection in AJAX CalendarExtender control in ASP.Net using C# and VB.Net.
 
 

Installing AjaxControlToolkit package using Nuget

In order to install AjaxControlToolkit library using Nuget, please refer my article Install AjaxControlToolkit library using Nuget.
 
 

HTML Markup

The HTML Markup consists of following controls:
ScriptManager – For enabling ASP.Net AJAX.
TextBox – For capturing the user input.
ImageButton – For displaying calendar icon.
CalendarExtender – For displaying calendar.
 
The AJAX CalendarExtender has been assigned with the following properties:
TargetControlID – The control where the Text will displayed.
PopupButtonID – The control which opens the Calendar.
 

Disabling Future date in ASP.Net AJAX CalendarExtender

The AJAX CalendarExtender has been assigned with the following property.
EndDate – For disabling the Future date selection.
Dates after the Date set in the EndDate property will be disabled, which means it cannot be selected.
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:TextBox ID="txtDate" runat="server" />
<asp:ImageButton ID="imgPopup" runat="server" ImageUrl="~/Image/calendar.gif" />
<ajaxToolkit:CalendarExtender ID="Calender1" runat="server" TargetControlID="txtDate" PopupButtonID="imgPopup" EndDate="12/30/2024" />
 
The above property can be set through Code-Behind in following way:
C#
//Disable Future Date
Calender1.EndDate = DateTime.Now;
 
VB.Net
'Disable Future Date
Calender1.EndDate = DateTime.Now
 
 

Screenshot

AJAX CalendarExtender: Disable Future Date Selection
 
 

Demo

 
 

Downloads