Export (0) Print
Expand All

Calendar.SelectedDayStyle Property

Gets the style properties for the selected dates.

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

public TableItemStyle SelectedDayStyle { get; }
/** @property */
public TableItemStyle get_SelectedDayStyle ()

public function get SelectedDayStyle () : TableItemStyle

Property Value

A TableItemStyle that contains the style properties for the selected dates. The default value is an empty TableItemStyle.

Use this property to specify the style for the selected dates on the Calendar control. If the SelectedDayStyle property is not set, the style specified in the DayStyle property is used.

For more information on the different style properties that can be controlled, see TableItemStyle.

The following code example demonstrates how to use the SelectedDayStyle property to specify a blue background color for the selected dates on the Calendar control.

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


   <form runat="server">

      <h3>Calendar Example</h3>

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

         <SelectedDayStyle BackColor="Blue">



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

   <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 = 


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

      Click a day, and then choose a background color for the selected day.

      <asp:Calendar id="Calendar1"


      <table cellpadding="5">



               Background color:





               <asp:DropDownList id="ColorList"

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





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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

© 2015 Microsoft