Calendar.VisibleMonthChanged イベント
アセンブリ: System.Web (system.web.dll 内)

Dim instance As Calendar Dim handler As MonthChangedEventHandler AddHandler instance.VisibleMonthChanged, handler
public: event MonthChangedEventHandler^ VisibleMonthChanged { void add (MonthChangedEventHandler^ value); void remove (MonthChangedEventHandler^ value); }


VisibleMonthChanged イベントのハンドラを指定およびコード化して、Calendar コントロールが 1 つ前の月に移動したのか、1 つ後の月に移動したのかを表示する方法を次のコード例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script runat="server"> Sub MonthChange(sender As Object, e As MonthChangedEventArgs) If e.NewDate.Month > e.PreviousDate.Month Then Message.Text = "You moved forward one month." Else Message.Text = "You moved backwards one month." End If End Sub </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>
<%@ 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>
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script runat="server"> Sub MonthChange(sender As Object, e As MonthChangedEventArgs) If e.NewDate.Month > e.PreviousDate.Month Then Message.Text = "You moved forward one month." Else Message.Text = "You moved backwards one month." End If End Sub Sub Page_Load(sender As Object, e As EventArgs) ' Manually register the event-handling method for the ' VisibleMonthChanged event of the Calendar control. AddHandler Calendar1.VisibleMonthChanged, AddressOf MonthChange End Sub </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>
<%@ 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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Calendar.VisibleMonthChanged イベントのページへのリンク