.aspx文件如下
<asp:Calendar ID="rili1" runat="server"
OnSelectionChanged="date_selected"
DayNameFormat="Full"
FirstDayOfWeek="Monday"
SelectionMode="DayWeek"
NextPrevFormat="ShortMonth"
SelectMonthText="month"
SelectWeekText="week"
DayHeaderStyle-BackColor="yellowGreen"
Height="243px" Width="594px">
<TodayDayStyle Font-Bold="True" ForeColor="Red" />
<WeekendDayStyle ForeColor="DarkGoldenrod" />
<DayHeaderStyle Font-Bold="True" />
<OtherMonthDayStyle ForeColor="Gray" />
<NextPrevStyle Font-Underline="true" ForeColor="blueViolet" />
<TitleStyle BackColor="HotPink" ForeColor="White" Font-Bold="True" />
<SelectedDayStyle BackColor="White" Font-Bold="True" />
<SelectorStyle BackColor="yellow" ForeColor="Navy" Font-Size="9pt" />
</asp:Calendar>
.cs代码如下
protected void date_selected(object sender, EventArgs e)
{
switch(rili1.SelectedDates.Count)
{
case(0):
{
Response.Write("您没有选择日期");
break;
}
case(1):
{
Response.Write("您选择的日期是"+rili1.SelectedDate.ToLongDateString());
break;
}
case(7):
{
Response.Write("您选择的是一周的开始");
break;
}
default:
Response.Write("您选择的是一个月的开始"+rili1.SelectedDate.ToShortDateString());
break;
}
}
这个程序是正确的但是红色的地方我不懂
给我解释哈
谢谢!
可以把代码粘贴回去试哈还挺有意思的!