Calendar.OtherMonthDayStyle Свойство

Определение

Возвращает свойства стиля для дней элемента управления Calendar, не содержащихся в отображаемом месяце.

public:
 property System::Web::UI::WebControls::TableItemStyle ^ OtherMonthDayStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.TableItemStyle OtherMonthDayStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.OtherMonthDayStyle : System.Web.UI.WebControls.TableItemStyle
Public ReadOnly Property OtherMonthDayStyle As TableItemStyle

Значение свойства

Объект TableItemStyle, содержащий свойства стиля для дней элемента управления Calendar, не принадлежащих к отображаемому месяцу. Значение по умолчанию — пустой объект TableItemStyle.

Атрибуты

Примеры

В следующем примере кода показано, как использовать OtherMonthDayStyle свойство , чтобы указать светло-серый цвет переднего плана для дней в элементе Calendar управления, которые не входят в текущий отображаемый месяц.

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

<!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 runat="server">
    <title>Calendar OtherMonthDayStyle Example</title>
<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 id="form1" 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>
<%@ Page Language="VB" AutoEventWireup="True" %>
<%@ Import Namespace="System.Drawing" %>

<!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 runat="server">
    <title>Calendar OtherMonthDayStyle Example</title>
<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 id="form1" 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>

Комментарии

Используйте это свойство, чтобы указать стиль дней в элементе Calendar управления, которые не относятся к отображаемого месяца. OtherMonthDayStyle Если свойство не задано, используется стиль, указанный в свойстве DayStyle .

Дополнительные сведения о различных свойствах стиля, которыми можно управлять, см. в разделе TableItemStyle.

Применяется к

См. также раздел