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

選択した日付のスタイル プロパティを格納している TableItemStyle。既定値は空の TableItemStyle です。

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

SelectedDayStyle プロパティを使用して、Calendar コントロールで選択された日付の背景色を青に指定する方法を次のコード例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> </head> <body> <form runat="server"> <h3>Calendar Example</h3> <asp:Calendar id="calendar1" runat="server" SelectionMode="DayWeekMonth"> <SelectedDayStyle BackColor="Blue"> </SelectedDayStyle> </asp:Calendar> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> </head> <body> <form runat="server"> <h3>Calendar Example</h3> <asp:Calendar id="calendar1" runat="server" SelectionMode="DayWeekMonth"> <SelectedDayStyle BackColor="Blue"> </SelectedDayStyle> </asp:Calendar> </form> </body> </html>
<%@ Page Language="JScript" AutoEventWireup="True" %> <html> <head> </head> <body> <form runat="server"> <h3>Calendar Example</h3> <asp:Calendar id="calendar1" runat="server" SelectionMode="DayWeekMonth"> <SelectedDayStyle BackColor="Blue"> </SelectedDayStyle> </asp:Calendar> </form> </body> </html>
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <script runat="server" > Sub Selection_Change(sender As Object, e As EventArgs) ' Set the background color for the selected day in the ' Calendar control. Calendar1.SelectedDayStyle.BackColor = _ System.Drawing.Color.FromName(ColorList.SelectedItem.Value) End Sub </script> <body> <form runat="server"> <h3> Calendar SelectedDayStyle Example </h3> Click a day, and then choose a background color for the selected day. <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="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>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <script runat="server" > void Selection_Change(Object sender, EventArgs e) { // Set the background color for the selected day in the // Calendar control. Calendar1.SelectedDayStyle.BackColor = System.Drawing.Color.FromName(ColorList.SelectedItem.Value); } </script> <body> <form runat="server"> <h3> Calendar SelectedDayStyle Example </h3> Click a day, and then choose a background color for the selected day. <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="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>

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.SelectedDayStyle プロパティのページへのリンク