Calendar コントロールに表示する月を指定する日付を取得または設定します。
名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文
'宣言
<BindableAttribute(True)> _
Public Property VisibleDate As DateTime
'使用
Dim instance As Calendar
Dim value As DateTime
value = instance.VisibleDate
instance.VisibleDate = value
[BindableAttribute(true)]
public DateTime VisibleDate { get; set; }
[BindableAttribute(true)]
public:
property DateTime VisibleDate {
DateTime get ();
void set (DateTime value);
}
/** @property */
public DateTime get_VisibleDate ()
/** @property */
public void set_VisibleDate (DateTime value)
public function get VisibleDate () : DateTime
public function set VisibleDate (value : DateTime)
適用できません。
プロパティ値
Calendar に表示する月を指定する System.DateTime。既定値は DateTime.MinValue で、TodaysDate で指定された日付を含む月が表示されます。
解説
VisibleDate プロパティを使用して、Calendar コントロールに表示する月をプログラムにより設定します。指定する日付は表示する月の中の任意の日付を指定できますが、通常はその月の最初の日付にします。このプロパティは System.DateTime オブジェクトを使用して設定します。
VisibleDate プロパティは、VisibleMonthChanged イベントが発生する前に更新されます。カスタムの OnVisibleMonthChanged イベント ハンドラを作成すると、VisibleDate プロパティを設定して自動的に生成された値をオーバーライドできます。
トピック | 場所 |
---|---|
方法 : Calendar Web サーバー コントロールにおける表示月の移動を制御する | Visual Studio ASP .NET での Web アプリケーションの作成 |
方法 : Calendar Web サーバー コントロールにおける表示月の移動を制御する | Visual Studio ASP .NET での Web アプリケーションの作成 |
方法 : Calendar Web サーバー コントロールにおける表示月の移動を制御する | ASP .NET Web アプリケーションの作成 |
使用例
VisibleDate プロパティを使用して、Calendar コントロールに表示される月を決定する値をプログラムによって設定する方法を次のコード例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Calendar Example</title>
<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 id="form1" 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" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Calendar Example</title>
<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 id="form1" 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" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Calendar Example</title>
<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 id="form1" 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 Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition
Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。
バージョン情報
.NET Framework
サポート対象 : 3.0,2.0,1.1,1.0
参照
関連項目
Calendar クラス
Calendar メンバ
System.Web.UI.WebControls 名前空間
System.DateTime
VisibleMonthChanged