How to disable Calendar past previous dates
DisableCalendarPastDates.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html>
<script runat="server">
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.Date < DateTime.Today)
{
e.Cell.Font.Italic = true;
e.Cell.Font.Size = FontUnit.XLarge;
e.Day.IsSelectable = false;
e.Cell.BackColor = System.Drawing.Color.DimGray;
e.Cell.BorderColor = System.Drawing.Color.Gray;
e.Cell.ForeColor = System.Drawing.Color.Gray;
e.Cell.Font.Name = "Courier New";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to disable Calendar past previous dates</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:SlateBlue; font-style:italic;">
How to disable Calendar past previous dates
</h2>
<hr width="475" align="left" color="SlateGray" />
<asp:Calendar
ID="Calendar1"
runat="server"
NextPrevFormat="FullMonth"
ForeColor="WhiteSmoke"
SelectionMode="Day"
DayNameFormat="Full"
Font-Names="Book Antiqua"
Font-Size="Medium"
OnDayRender="Calendar1_DayRender"
>
<DayHeaderStyle
BackColor="OliveDrab"
/>
<DayStyle
BackColor="DarkOrchid"
BorderColor="IndianRed"
BorderWidth="1"
Font-Bold="true"
Font-Italic="true"
Font-Size="Large"
/>
<NextPrevStyle
Font-Italic="true"
Font-Names="Arial CE"
/>
<SelectedDayStyle
BackColor="Green"
BorderColor="SpringGreen"
/>
<TitleStyle
BackColor="MidnightBlue"
Height="36"
Font-Size="Large"
Font-Names="Courier New Baltic"
/>
</asp:Calendar>
</div>
</form>
</body>
</html>



