Friday, September 5, 2008

How To Make Previous Calendar Dates Not Selectable in ASP.NET

In order to make all dates before the current date, not able to be selected, in the onDayRender event for your Calendar:
if (e.Day.Date < DateTime.Today)
{
    e.Day.IsSelectable = false;
}
To make it more obvious to the end user, also add:
e.Cell.BackColor = Drawing.Color.GhostWhite;
e.Cell.ForeColor = Drawing.Color.Gainsboro;

Source: https://www.nilebits.com/blog/2008/03/make-previous-calendar-dates-not-selectable-asp-dot-net/

No comments:

Post a Comment