asp.net calendar control. Date selectable after 2

2019-08-07 01:28发布

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?

2条回答
Bombasti
2楼-- · 2019-08-07 02:06

Put this in your page load:

Calendar1.SelectedDate = DateTime.Now.AddDays(2);
查看更多
beautiful°
3楼-- · 2019-08-07 02:14

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;
}
查看更多
登录 后发表回答