I have this calender in my webpage and i want that user choose only the weekdays that i specify in my code behind and the rest of the days are disabled( for example user could only choose Monday,Tuesday and Thursday of the weeks).
I should use this method but i don't know how can i do that, if someone could help?
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
}
解决方案
You could use the CalendarDay.IsSelectable and the IsWeekEnd properties:
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
e.Day.IsSelectable = !e.Day.IsWeekend;
}
Edit: i thought that you only want weekdays, if you want to specify the days:
private DayOfWeek[] AllowedDays = { DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Thursday };
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
e.Day.IsSelectable = AllowedDays.Contains(e.Day.Date.DayOfWeek);
}