Calendar.VisibleDate プロパティ
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)

Dim instance As Calendar Dim value As DateTime value = instance.VisibleDate instance.VisibleDate = value
[BindableAttribute(true)] public: property DateTime VisibleDate { DateTime get (); void set (DateTime value); }
/** @property */ public DateTime get_VisibleDate () /** @property */ public void set_VisibleDate (DateTime value)
表示する月を指定する日付。既定値は DateTime.MinValue です。

VisibleDate プロパティは、Calendar.VisibleMonthChanged イベントが発生した後に更新されます。

VisibleDate プロパティを使用して、カレンダーに表示する日付を設定する方法のコード例を次に示します。このコード例は、Calendar の概要で取り上げているコード例の一部です。

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


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

Dim instance As Calendar Dim value As DateTime value = instance.VisibleDate instance.VisibleDate = value
[BindableAttribute(true)] public: property DateTime VisibleDate { DateTime get (); void set (DateTime value); }
/** @property */ public DateTime get_VisibleDate () /** @property */ public void set_VisibleDate (DateTime value)
Calendar に表示する月を指定する System.DateTime。既定値は DateTime.MinValue で、TodaysDate で指定された日付を含む月が表示されます。

VisibleDate プロパティを使用して、Calendar コントロールに表示する月をプログラムにより設定します。指定する日付は表示する月の中の任意の日付を指定できますが、通常はその月の最初の日付にします。このプロパティは System.DateTime オブジェクトを使用して設定します。
VisibleDate プロパティは、VisibleMonthChanged イベントが発生する前に更新されます。カスタムの OnVisibleMonthChanged イベント ハンドラを作成すると、VisibleDate プロパティを設定して自動的に生成された値をオーバーライドできます。

VisibleDate プロパティを使用して、Calendar コントロールに表示される月を決定する値をプログラムによって設定する方法を次のコード例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script language="VB" runat="server"> Sub ButtonClick(sender As Object, e As EventArgs) Calendar1.VisibleDate = New DateTime(Calendar1.TodaysDate.Year, DropList1.SelectedIndex + 1, 1) Label1.Text = "The VisibleDate property is " & Calendar1.VisibleDate.ToShortDateString() End Sub 'ButtonClick </script> </head> <body> <form runat="server"> <h3>Calendar Example</h3> <asp:Calendar id="Calendar1" runat="server" SelectionMode="None" ShowGridLines="True"> <SelectedDayStyle BackColor="Yellow" ForeColor="Red"> </SelectedDayStyle> </asp:Calendar> <hr><br> Select the month to display: <br> <asp:DropDownList id="DropList1" runat="server"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> <asp:ListItem>4</asp:ListItem> <asp:ListItem>5</asp:ListItem> <asp:ListItem>6</asp:ListItem> <asp:ListItem>7</asp:ListItem> <asp:ListItem>8</asp:ListItem> <asp:ListItem>9</asp:ListItem> <asp:ListItem>10</asp:ListItem> <asp:ListItem>11</asp:ListItem> <asp:ListItem>12</asp:ListItem> </asp:DropDownList> <asp:Button id="Button1" Text="Submit" OnClick="ButtonClick" runat=server /> <br><br> <asp:Label id="Label1" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script language="C#" runat="server"> void ButtonClick(Object sender, EventArgs e) { Calendar1.VisibleDate = new DateTime(Calendar1.TodaysDate.Year, DropList1.SelectedIndex + 1, 1); Label1.Text = "The VisibleDate property is " + Calendar1.VisibleDate.ToShortDateString(); } </script> </head> <body> <form runat="server"> <h3>Calendar Example</h3> <asp:Calendar id="Calendar1" runat="server" SelectionMode="None" ShowGridLines="True"> <SelectedDayStyle BackColor="Yellow" ForeColor="Red"> </SelectedDayStyle> </asp:Calendar> <hr><br> Select the month to display: <br> <asp:DropDownList id="DropList1" runat="server"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> <asp:ListItem>4</asp:ListItem> <asp:ListItem>5</asp:ListItem> <asp:ListItem>6</asp:ListItem> <asp:ListItem>7</asp:ListItem> <asp:ListItem>8</asp:ListItem> <asp:ListItem>9</asp:ListItem> <asp:ListItem>10</asp:ListItem> <asp:ListItem>11</asp:ListItem> <asp:ListItem>12</asp:ListItem> </asp:DropDownList> <asp:Button id="Button1" Text="Submit" OnClick="ButtonClick" runat=server /> <br><br> <asp:Label id="Label1" runat="server"/> </form> </body> </html>
<%@ Page Language="JScript" AutoEventWireup="True" %> <html> <head> <script language="JScript" runat="server"> function ButtonClick(sender : Object, e : EventArgs) { Calendar1.VisibleDate = new DateTime(Calendar1.TodaysDate.Year, DropList1.SelectedIndex + 1, 1); Label1.Text = "The VisibleDate property is " + Calendar1.VisibleDate.ToShortDateString(); } </script> </head> <body> <form runat="server"> <h3>Calendar Example</h3> <asp:Calendar id="Calendar1" runat="server" SelectionMode="None" ShowGridLines="True"> <SelectedDayStyle BackColor="Yellow" ForeColor="Red"> </SelectedDayStyle> </asp:Calendar> <hr><br> Select the month to display: <br> <asp:DropDownList id="DropList1" runat="server"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> <asp:ListItem>4</asp:ListItem> <asp:ListItem>5</asp:ListItem> <asp:ListItem>6</asp:ListItem> <asp:ListItem>7</asp:ListItem> <asp:ListItem>8</asp:ListItem> <asp:ListItem>9</asp:ListItem> <asp:ListItem>10</asp:ListItem> <asp:ListItem>11</asp:ListItem> <asp:ListItem>12</asp:ListItem> </asp:DropDownList> <asp:Button id="Button1" Text="Submit" OnClick="ButtonClick" runat=server /> <br><br> <asp:Label id="Label1" runat="server"/> </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.VisibleDate プロパティのページへのリンク