Export (0) Print
Expand All
2 out of 3 rated this helpful - Rate this topic

Calendar.OtherMonthDayStyle Property

Gets the style properties for the days on the Calendar control that are not in the displayed month.

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

public TableItemStyle OtherMonthDayStyle { get; }
/** @property */
public TableItemStyle get_OtherMonthDayStyle ()

public function get OtherMonthDayStyle () : TableItemStyle

Property Value

A TableItemStyle that contains the style properties for the days on the Calendar control that are not in the displayed month. The default value is an empty TableItemStyle.

Use this property to specify the style for the days on the Calendar control that are not in the displayed month. If the OtherMonthDayStyle 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 OtherMonthDayStyle property to specify a light gray foreground color for the days on the Calendar control that are not in the currently displayed month.

<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Drawing" %>

<html>
<head>

   <script runat="server">

      void Index_Changed(Object sender, EventArgs e)
      {

         // Set the foreground color of days not in the current
         // month to the color selected from the DropDownList control.
         Calendar1.OtherMonthDayStyle.ForeColor = 
            Color.FromName(ColorList.SelectedItem.Value);

      }

   </script>

</head>
<body>

   <form runat="server">

      <h3>Calendar OtherMonthDayStyle Example</h3>

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

         <OtherMonthDayStyle ForeColor="LightGray">
         </OtherMonthDayStyle>

      </asp:Calendar>

      <br><br>

      Select a color for the days not in the current month:

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

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

      </asp:DropDownList>      
            
   </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

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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.