Calendar.DayHeaderStyle Property

 

Gets the style properties for the section that displays the day of the week.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

[PersistenceModeAttribute(PersistenceMode.InnerProperty)]
public TableItemStyle DayHeaderStyle { get; }

Property Value

Type: System.Web.UI.WebControls.TableItemStyle

A TableItemStyle that contains the style properties for the section that displays the day of the week. The default value is an empty TableItemStyle.

Use this property to specify the style for the section that displays the days of the week. For more information on the different style properties that can be controlled, see TableItemStyle.

System_CAPS_noteNote

The name format for the days of the week is controlled by the DayNameFormat property.

This property applies only when the ShowDayHeader property is set to true.

The following code example demonstrates how to use the DayHeaderStyle property to specify a bold font for the section that displays the days of the week.

<%@ 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>
</head>
<body>

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

      <h3>Calendar Example</h3>

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

         <DayHeaderStyle Font-Bold="true">
         </DayHeaderStyle>

      </asp:Calendar>

   </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" >
   <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>

<head runat="server">
    <title> Calendar DayHeaderStyle Example </title>
</head>
<body>

   <form id="form1" 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>

      </table>

   </form>

</body>
</html>

.NET Framework
Available since 1.1
Return to top
Show: