In this article I will explain with an example, how to disable Past or Previous 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 Past or Previous date in ASP.Net AJAX CalendarExtender

The AJAX CalendarExtender has been assigned with the following property.
StartDate – For disabling the Past or Previous date selection.
Dates before the Date set in the StartDate 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" StartDate="12/31/2024" />
 
The above property can be set through Code-Behind in following way:
C#
//Disable Past Date
Calender1.StartDate = DateTime.Now;
 
VB.Net
'Disable Past Date
Calender1.StartDate = DateTime.Now
 
 

Screenshot

AJAX CalendarExtender: Disable Past Date Selection
 
 

Demo

 
 

Downloads