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;

Hire Me

Follow me on Facebook

Follow me

Do you find this Blog helpful?

Follow by Email

About Me

My Photo
Expert Senior Software Developer

Microsoft Business Card