Question:You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
To add a Calendar server control to a Web page, you write the following code fragment:
<asp:Calendar SelectionMode="DayWeek" ID="Calendar1" runat="server">
</asp:Calendar>
You need to disable the non-week days in the Calendar control.
What should you do?
A Add the following code segment to the Calendar1 DayRender event handler:
if (e.Day.IsWeekend) {
Day.IsSelectable = false;
}
B Add the following code segment to the Calendar1 DayRender event handler:
if (e.Day.IsWeekend) {
if (Calendar1.SelectedDates.Contains(e.Day.Date))
Calendar1.SelectedDates.Remove(e.Day.Date);
}
C Add the following code segment to the Calendar1 SelectionChanged event handler:
List<DateTime> list = new List<DateTime>();
foreach (DateTime st in (sender as Calendar).SelectedDates) {
if (st.DayOfWeek == DayOfWeek.Saturday || st.DayOfWeek == DayOfWeek.Sunday) {
list.Add(st);
}
}
foreach (DateTime dt in list) {
(sender as Calendar).SelectedDates.Remove(dt);
}
D Add the following code segment to the Calendar1 DataBinding event handler:
List<DateTime> list = new List<DateTime>();
foreach (DateTime st in (sender as Calendar).SelectedDates) {
if (st.DayOfWeek == DayOfWeek.Saturday || st.DayOfWeek == DayOfWeek.Sunday) {
list.Add(st);
}
}
foreach (DateTime dt in list) {
(sender as Calendar).SelectedDates.Remove(dt);
}