MonthChangedEventArgs.NewDate プロパティ
アセンブリ: System.Web (system.web.dll 内)

Calendar によって現在表示されている月を決定する日付。

このプロパティを使用して、Calendar コントロールによって現在表示されている月を取得し、その月を別の月と比較します。たとえば、このプロパティを使用して、特定の日付まで、またはその日付以降の月の数を計算できます。
通常、この日付は現在表示されている月の最初の日ですが、プログラムによってその月の任意の日付に変更できます。
VisibleDate プロパティは、ユーザーが Calendar コントロールのナビゲーション コントロールをクリックしたときに月の変更をオーバーライドできるように、プログラムによってこのプロパティに割り当てられます。

NewDate プロパティと PreviousDate プロパティの月を比較して、Calendar コントロールが前月に移動したか翌月に移動したかを決定する方法を次のコード例に示します。
<%@ 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>

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- MonthChangedEventArgs.NewDate プロパティのページへのリンク