Asp.net日历在页面加载事件中选择当前周

时间:2010-07-06 18:49:56

标签: asp.net calendar

1 个答案:

答案 0 :(得分:1)

尝试一下:

Calendar1.SelectionMode = CalendarSelectionMode.DayWeek;  
ArrayList selectedDates = new ArrayList();  
DateTime today = DateTime.Now;    
DateTime firstDay = today.AddDays(-(double)(today.DayOfWeek));    
for (int loop = 0; loop < 7; loop++)    
    Calendar1.SelectedDates.Add(firstDay.AddDays(loop));