This documentation is archived and is not being maintained.

Calendar.DayNameFormat Property

Gets or sets the name format of days of the week.

[Visual Basic]
Public Property DayNameFormat As DayNameFormat
[C#]
public DayNameFormat DayNameFormat {get; set;}
[C++]
public: __property DayNameFormat get_DayNameFormat();
public: __property void set_DayNameFormat(DayNameFormat);
[JScript]
public function get DayNameFormat() : DayNameFormat;
public function set DayNameFormat(DayNameFormat);

Property Value

One of the DayNameFormat values. The default value is Short.

Exceptions

Exception Type Condition
ArgumentException The specified day name format is not one of the DayNameFormat values.

Remarks

Use the DayNameFormat property to specify the name format for the days of the week. This property is set with one of the DayNameFormat enumeration values. You can specify whether the days of the week are displayed as the full name, short (abbreviated) name, first letter of the day, or first two letters of the day.

This property only applies if the ShowDayHeader property is set to true.

The day names are based on the server's local settings.

Example

[Visual Basic, C#, JScript] The following example demonstrates how to use the DayNameFormat property to specify that days of the week are displayed in full.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>

</head>
<body>

   <form runat="server">

      <h3>Calendar Example</h3>

      <asp:Calendar id="calendar1" runat="server"
           ShowDayHeader="True"
           DayNameFormat="Full"/>
            
   </form>
        

</body>
</html>


[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>

</head>
<body>

   <form runat="server">

      <h3>Calendar Example</h3>

      <asp:Calendar id="calendar1" runat="server"
           ShowDayHeader="True"
           DayNameFormat="Full"/>
            
   </form>
        

</body>
</html>


[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>
<html>
<head>

</head>
<body>

   <form runat="server">

      <h3>Calendar Example</h3>

      <asp:Calendar id="calendar1" runat="server"
           ShowDayHeader="True"
           DayNameFormat="Full"/>
            
   </form>
        

</body>
</html>


[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
   <script runat="server" >
  
      Sub Selection_Change(sender As Object, e As EventArgs)

         ' Set display format for the days of the week.
         Calendar1.DayNameFormat = _
            CType(DayNameList.SelectedIndex, DayNameFormat)

      End Sub
  
   </script>
  
<body>

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

      Select a display style for the days of the week.

      <br><br> 
  
      <asp:Calendar id="Calendar1"
           ShowGridLines="True" 
           ShowTitle="True"
           runat="server"/>

      <br><br>

      <table cellpadding="5">

         <tr>

            <td>

               Format:

            </td>

         </tr>

         <tr>

            <td>

               <asp:DropDownList id="DayNameList"
                    AutoPostBack="True"
                    OnSelectedIndexChanged="Selection_Change"
                    runat="server">

                  <asp:ListItem> Full </asp:ListItem>
                  <asp:ListItem Selected="True"> Short </asp:ListItem>
                  <asp:ListItem> FirstLetter </asp:ListItem>
                  <asp:ListItem> FirstTwoLetters </asp:ListItem>

               </asp:DropDownList>

            </td>

         </tr>
  
   </form>

</body>
</html>
 

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

<html>
   <script runat="server" >
  
      void Selection_Change(Object sender, EventArgs e)
      {

         // Set display format for the days of the week.
         Calendar1.DayNameFormat = 
            (DayNameFormat)DayNameList.SelectedIndex;

      }
  
   </script>
  
<body>

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

      Select a display style for the days of the week.

      <br><br> 
  
      <asp:Calendar id="Calendar1"
           ShowGridLines="True" 
           ShowTitle="True"
           runat="server"/>

      <br><br>

      <table cellpadding="5">

         <tr>

            <td>

               Format:

            </td>

         </tr>

         <tr>

            <td>

               <asp:DropDownList id="DayNameList"
                    AutoPostBack="True"
                    OnSelectedIndexChanged="Selection_Change"
                    runat="server">

                  <asp:ListItem> Full </asp:ListItem>
                  <asp:ListItem Selected="True"> Short </asp:ListItem>
                  <asp:ListItem> FirstLetter </asp:ListItem>
                  <asp:ListItem> FirstTwoLetters </asp:ListItem>

               </asp:DropDownList>

            </td>

         </tr>
  
   </form>

</body>
</html>
 

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript 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 | DayNameFormat | ShowDayHeader

Show: