1

Is it possible to restrict which dates are selectable in the calendar control eg so that a date can only be selected once it's at least two days ago?

kaj
  • 5,133
  • 2
  • 21
  • 18
pikk
  • 837
  • 5
  • 21
  • 38

2 Answers2

3

You can handle the calendar control's DayRender event to control which days are visible/selectable (as seen in this forum discussion):

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
    if (e.Day.Date >= DateTime.Now.Date && e.Day.Date <= DateTime.Now.AddDays(2))
        e.Cell.Visible = true;
    else
        e.Cell.Visible = false;
}
M.Babcock
  • 18,753
  • 6
  • 54
  • 84
1

Put this in your page load:

Calendar1.SelectedDate = DateTime.Now.AddDays(2);
Alex
  • 5,971
  • 11
  • 42
  • 80
  • I assume that he not only wants to select that date but to prevent that the user can select date earlier than the day after tomorrow(see M.Babcock link in his comment). – Tim Schmelter Feb 29 '12 at 14:46