Calendar.DayHeaderStyle Property
Gets the style properties for the section that displays the day of the week.
[Visual Basic] Public ReadOnly Property DayHeaderStyle As TableItemStyle [C#] public TableItemStyle DayHeaderStyle {get;} [C++] public: __property TableItemStyle* get_DayHeaderStyle(); [JScript] public function get DayHeaderStyle() : TableItemStyle;
Property Value
A TableItemStyle object that contains the style properties for the section that displays the day of the week. The default value is an empty TableItemStyle object.
Remarks
Use this property to specify the style for the section that displays the days of the week. For additional information on the different style properties that can be controlled, see TableItemStyle.
Note The name format for the days of the week is controlled by the DayNameFormat property.
This property only applies when the ShowDayHeader property is set to true.
Example
[Visual Basic, C#, JScript] The following example demonstrates how to use the DayHeaderStyle property to specify a bold font for the section that displays the days of the week.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> </head> <body> <form runat="server"> <h3>Calendar Example</h3> <asp:Calendar id="calendar1" runat="server" ShowDayHeader="True"> <DayHeaderStyle Font-Bold="true"> </DayHeaderStyle> </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" ShowDayHeader="True"> <DayHeaderStyle Font-Bold="true"> </DayHeaderStyle> </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" ShowDayHeader="True"> <DayHeaderStyle Font-Bold="true"> </DayHeaderStyle> </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 the heading section of ' the Calendar control. Calendar1.DayHeaderStyle.BackColor = _ System.Drawing.Color.FromName(ColorList.SelectedItem.Value) End Sub </script> <body> <form runat="server"> <h3> Calendar DayHeaderStyle Example </h3> Select a background color for the heading section. <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 the heading section of // the Calendar control. Calendar1.DayHeaderStyle.BackColor = System.Drawing.Color.FromName(ColorList.SelectedItem.Value); } </script> <body> <form runat="server"> <h3> Calendar DayHeaderStyle Example </h3> Select a background color for the heading section. <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++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
Calendar Class | Calendar Members | System.Web.UI.WebControls Namespace | TableItemStyle | ShowDayHeader | DayNameFormat