日期:2014-05-18  浏览次数:20997 次

请教高手:C#中怎样触发Calendar中改变月的事件
比如点击上一月或下一月时如何实现?还有就是选中日或周时样式怎么没变化?


------解决方案--------------------
知道的高手来啊,我也想知道
------解决方案--------------------
protected void cal1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
{
lblDateTime .Text = e.NewDate.Month.ToString();
}
------解决方案--------------------
<%@ Page Language= "C# " AutoEventWireup= "True " %>

<html>

<head>

<script runat= "server ">

void MonthChange(Object sender, MonthChangedEventArgs e)
{

if (e.NewDate.Month > e.PreviousDate.Month)
{
Message.Text = "You moved forward one month. ";
}
else
{
Message.Text = "You moved backwards one month. ";
}

}

</script>

</head>

<body>

<form runat= "server ">

<h3> Calendar VisibleMonthChanged Example </h3>

Select a different month on the calendar.
<br> <br>

<asp:Calendar id= "Calendar1 " runat= "server "
OnVisibleMonthChanged= "MonthChange ">

<WeekendDayStyle BackColor= "gray ">
</WeekendDayStyle>

</asp:Calendar>

<hr>

<table border= "1 ">

<tr bgcolor= "Silver ">

<th>

Month navigation direction

</th>
</tr>

<tr>

<td>

<asp:Label id= "Message "
Text= "Starting month. "
runat= "server "/>

</td>

</tr>

</table>

</form>

</body>

</html>