This documentation is archived and is not being maintained.

Calendar.OtherMonthDayStyle Property

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

[Visual Basic]
Public ReadOnly Property OtherMonthDayStyle As TableItemStyle
[C#]
public TableItemStyle OtherMonthDayStyle {get;}
[C++]
public: __property TableItemStyle* get_OtherMonthDayStyle();
[JScript]
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 object.

Remarks

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 additional information on the different style properties that can be controlled, see TableItemStyle.

Example

[Visual Basic, C#] The following 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.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>
<%@ Import Namespace="System.Drawing" %>

<html>
<head>

   <script runat="server">

      Sub Index_Changed(sender As Object, e As EventArgs)

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

      End Sub

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


[C#] 
<%@ 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>

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter 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 | DayStyle

Show: