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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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;
}
回答2:
Put this in your page load:
Calendar1.SelectedDate = DateTime.Now.AddDays(2);