Calendar.TodaysDate プロパティ

定義

今日の日付の値を取得または設定します。

public:
 property DateTime TodaysDate { DateTime get(); void set(DateTime value); };
[System.ComponentModel.Bindable(true)]
[System.ComponentModel.Browsable(false)]
public DateTime TodaysDate { get; set; }
[System.ComponentModel.Browsable(false)]
public DateTime TodaysDate { get; set; }
[<System.ComponentModel.Bindable(true)>]
[<System.ComponentModel.Browsable(false)>]
member this.TodaysDate : DateTime with get, set
[<System.ComponentModel.Browsable(false)>]
member this.TodaysDate : DateTime with get, set
Public Property TodaysDate As DateTime

プロパティ値

DateTime

DateTime が今日の日付と見なしている値を格納している Calendar。 このプロパティが明示的に設定されていない場合は、サーバーの日付が使用されます。

属性

次のコード例は、プロパティを使用 TodaysDate してプログラムによってコントロールの今日の日付の値を設定する方法を Calendar 示しています。

<%@ 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 Selection_Change(Object sender, EventArgs e) 
      {
         Calendar1.TodaysDate = Calendar1.SelectedDate;
         Label1.Text = "Today's Date is now " + Calendar1.TodaysDate.ToShortDateString();
      }

   </script>

</head>     
<body>

   <form id="form1" runat="server">

      <h3>Calendar Example</h3>

      Select a date on the Calendar control to use as today's date.<br /><br />

      <asp:Calendar ID="Calendar1" runat="server"  
           SelectionMode="Day" 
           ShowGridLines="True" 
           OnSelectionChanged="Selection_Change">

         <SelectedDayStyle BackColor="Yellow"
                           ForeColor="Red">
         </SelectedDayStyle>

      </asp:Calendar> 

      <hr /><br />

      <asp:Label id="Label1" runat="server" />

   </form>
</body>
</html>
<%@ 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 Selection_Change(sender As Object, e As EventArgs)
            Calendar1.TodaysDate = Calendar1.SelectedDate
            Label1.Text = "Today's Date is now " & Calendar1.TodaysDate.ToShortDateString()
        End Sub 'Selection_Change

   </script>

</head>     
<body>

   <form id="form1" runat="server">

      <h3>Calendar Example</h3>

      Select a date on the Calendar control to use as today's date.<br /><br />

      <asp:Calendar ID="Calendar1" runat="server"  
           SelectionMode="Day" 
           ShowGridLines="True" 
           OnSelectionChanged="Selection_Change">

         <SelectedDayStyle BackColor="Yellow"
                           ForeColor="Red">
         </SelectedDayStyle>

      </asp:Calendar> 

      <hr /><br />

      <asp:Label id="Label1" runat="server" />

   </form>
</body>
</html>

注釈

プロパティを TodaysDate 使用して、今日の日付を決定します。 また、このプロパティを使用して、プログラムによってコントロールの今日の日付の値を Calendar 設定することもできます。 このプロパティは、オブジェクトを System.DateTime 使用して設定されます。

注意

この日付は、別のタイム ゾーンにいるユーザーに合わせて調整する必要がある場合があります。

プロパティで指定された日付の外観は、 TodaysDate プロパティを使用 TodayDayStyle してカスタマイズできます。

注意

プロパティが VisibleDate 設定されていない場合、プロパティで指定された日付によって TodaysDate 、コントロールに表示される月が Calendar 決まります。

適用対象

こちらもご覧ください