Calendar.TodayDayStyle プロパティ

Calendar コントロールの今日の日付のスタイル プロパティを取得します。

Public ReadOnly Property TodayDayStyle As TableItemStyle
[C#]
public TableItemStyle TodayDayStyle {get;}
[C++]
public: __property TableItemStyle* get_TodayDayStyle();
[JScript]
public function get TodayDayStyle() : TableItemStyle;

プロパティ値

Calendar コントロールの今日の日付のスタイル プロパティを格納している TableItemStyle 。既定値は空の TableItemStyle オブジェクトです。

解説

このプロパティを使用して、 Calendar コントロールの今日の日付のスタイルを指定します。 TodayDayStyle プロパティが設定されていない場合は、 DayStyle プロパティで指定したスタイルが使用されます。

制御できるさまざまなスタイル プロパティの詳細については、 TableItemStyle のトピックを参照してください。

使用例

[Visual Basic, C#, JScript] TodayDayStyle プロパティを使用して、今日の日付の背景色を青に、前景色を黄色に指定する方法を次の例に示します。

 
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>

</head>
<body>

   <form runat="server">

      <h3>Calendar Example</h3>

      <asp:Calendar id="calendar1" runat="server">

         <TodayDayStyle BackColor="Blue"
                        ForeColor="Yellow">
         </TodayDayStyle>

      </asp:Calendar>
            
   </form>       

</body>
</html>


[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>

</head>
<body>

   <form runat="server">

      <h3>Calendar Example</h3>

      <asp:Calendar id="calendar1" runat="server">

         <TodayDayStyle BackColor="Blue"
                        ForeColor="Yellow">
         </TodayDayStyle>

      </asp:Calendar>
            
   </form>       

</body>
</html>


[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>
<html>
<head>

</head>
<body>

   <form runat="server">

      <h3>Calendar Example</h3>

      <asp:Calendar id="calendar1" runat="server">

         <TodayDayStyle BackColor="Blue"
                        ForeColor="Yellow">
         </TodayDayStyle>

      </asp:Calendar>
            
   </form>       

</body>
</html>


[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
   <script runat="server" >
  
      Sub Selection_Change(sender As Object, e As EventArgs)

         ' Set the background color for today's date in the Calendar.
         Calendar1.TodayDayStyle.BackColor = _
            System.Drawing.Color.FromName(ColorList.SelectedItem.Value)

      End Sub
  
   </script>
  
<body>

   <form runat="server">
  
      <h3> Calendar TodayDayStyle Example </h3>

      Select a background color for today's date in the calendar.

      <br><br> 
  
      <asp:Calendar id="Calendar1"
           ShowGridLines="True" 
           ShowTitle="True"
           runat="server"/>

      <br><br>

      <table cellpadding="5">

         <tr>

            <td>

               Background color:

            </td>

         </tr>

         <tr>

            <td>

               <asp:DropDownList id="ColorList"
                    AutoPostBack="True"
                    OnSelectedIndexChanged="Selection_Change"
                    runat="server">

                  <asp:ListItem Selected="True" Value="White"> White </asp:ListItem>
                  <asp:ListItem Value="Silver"> Silver </asp:ListItem>
                  <asp:ListItem Value="DarkGray"> Dark Gray </asp:ListItem>
                  <asp:ListItem Value="Khaki"> Khaki </asp:ListItem>
                  <asp:ListItem Value="DarkKhaki"> Dark Khaki </asp:ListItem>

               </asp:DropDownList>

            </td>

         </tr>
  
   </form>

</body>
</html>
 

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
   <script runat="server" >
  
      void Selection_Change(Object sender, EventArgs e)
      {

         // Set the background color for today's date in the Calendar.
         Calendar1.TodayDayStyle.BackColor = 
            System.Drawing.Color.FromName(ColorList.SelectedItem.Value);

      }
  
   </script>
  
<body>

   <form runat="server">
  
      <h3> Calendar TodayDayStyle Example </h3>

      Select a background color for today's date in the calendar.

      <br><br> 
  
      <asp:Calendar id="Calendar1"
           ShowGridLines="True" 
           ShowTitle="True"
           runat="server"/>

      <br><br>

      <table cellpadding="5">

         <tr>

            <td>

               Background color:

            </td>

         </tr>

         <tr>

            <td>

               <asp:DropDownList id="ColorList"
                    AutoPostBack="True"
                    OnSelectedIndexChanged="Selection_Change"
                    runat="server">

                  <asp:ListItem Selected="True" Value="White"> White </asp:ListItem>
                  <asp:ListItem Value="Silver"> Silver </asp:ListItem>
                  <asp:ListItem Value="DarkGray"> Dark Gray </asp:ListItem>
                  <asp:ListItem Value="Khaki"> Khaki </asp:ListItem>
                  <asp:ListItem Value="DarkKhaki"> Dark Khaki </asp:ListItem>

               </asp:DropDownList>

            </td>

         </tr>
  
   </form>

</body>
</html>
 

[C++] C++ のサンプルはありません。Visual Basic、C#、および JScript のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ

参照

Calendar クラス | Calendar メンバ | System.Web.UI.WebControls 名前空間 | DayStyle | TableItemStyle