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

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

------解决方案--------------------
我也想知道啊
------解决方案--------------------
<%@ 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. ";
}

}

void Page_Load(Object sender, EventArgs e)
{

// Manually register the event-handling method for the
// VisibleMonthChanged event of the Calendar control.
Calendar1.VisibleMonthChanged +=
new MonthChangedEventHandler(this.MonthChange);

}

</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 ">

<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>