Share via


Calendar.DayStyle Propriété

Définition

Obtient les propriétés de style pour les jours du mois affiché.

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

Valeur de propriété

TableItemStyle

Objet TableItemStyle qui contient les propriétés de style pour les jours du mois affiché. La valeur par défaut est un TableItemStyle vide.

Attributs

Exemples

L’exemple de code suivant montre comment utiliser la DayStyle propriété pour spécifier que les jours du mois actuellement affiché sont affichés en gris.

<%@ 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">

         <DayStyle BackColor="gray">
         </DayStyle>

      </asp:Calendar>
            
   </form>
        

</body>
</html>

<html>
<head>

</head>
<body>

   <form runat="server">

      <h3><font face="Verdana">Calendar Example</font></h3>

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

         <DayStyle BackColor="gray">
         </DayStyle>

      </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 days in the Calendar control.
         Calendar1.DayStyle.BackColor = 
            System.Drawing.Color.FromName(ColorList.SelectedItem.Value);

      }
  
   </script>
  
<head runat="server">
    <title> Calendar DayStyle Example </title>
</head>
<body>

   <form id="form1" runat="server">
  
      <h3> Calendar DayStyle Example </h3>

      Select a background color for days in the calendar.

      <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>
<%@ Page Language="VB" 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" >
  
      Sub Selection_Change(sender As Object, e As EventArgs)

         ' Set the background color for days in the Calendar control.
         Calendar1.DayStyle.BackColor = _
            System.Drawing.Color.FromName(ColorList.SelectedItem.Value)

      End Sub
  
   </script>
  
<head runat="server">
    <title> Calendar DayStyle Example </title>
</head>
<body>

   <form id="form1" runat="server">
  
      <h3> Calendar DayStyle Example </h3>

      Select a background color for days in the calendar.

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

Remarques

Utilisez cette propriété pour spécifier le style des jours dans le mois affiché.

Notes

Si vous ne spécifiez pas de style différent pour la date sélectionnée, les dates du week-end, les dates non indiquées dans le mois actuellement affiché ou la date d’aujourd’hui, ces dates seront également affichées à l’aide du style spécifié par la DayStyle propriété. Utilisez les propriétés , et WeekendDayStyleOtherMonthDayStyleTodayDayStyle les SelectedDayStylepropriétés pour spécifier d’autres styles pour ces dates.

Pour plus d’informations sur les différentes propriétés de style qui peuvent être contrôlées, consultez TableItemStyle.

S’applique à

Voir aussi