Export (0) Print
Expand All

Calendar.NextPrevFormat Property

Gets or sets the format of the next and previous month navigation elements in the title section of the Calendar control.

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

public NextPrevFormat NextPrevFormat { get; set; }
<asp:Calendar NextPrevFormat="NextPrevFormat" />

Property Value

Type: System.Web.UI.WebControls.NextPrevFormat
One of the NextPrevFormat values. The default value is CustomText.

ExceptionCondition
ArgumentOutOfRangeException

The specified format is not one of the NextPrevFormat values.

Use the NextPrevFormat property to specify the format for the next and previous month navigation elements on the Calendar control. This property is set with one of the NextPrevFormat enumeration values. You can specify whether the text for the navigation controls is displayed as the full month name, the short (abbreviated) month name, or custom text.

To specify custom navigation text, set this property to NextPrevFormat.CustomText and set the NextMonthText and PrevMonthText properties to the custom text.

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

TopicLocation
How to: Customize Calendar Web Server Control AppearanceBuilding ASP .NET Web Applications
How to: Customize Calendar Web Server Control AppearanceBuilding ASP .NET Web Applications

The following code example demonstrates how to use the NextPrevFormat property to specify the short month format for the navigation controls.

<%@ 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"
           ShowNextPrevMonth="true"
           NextPrevFormat="ShortMonth"/>

   </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 format for the next and previous month controls.
         Calendar1.NextPrevFormat = (NextPrevFormat)DayList.SelectedIndex;

      }

   </script>

<head runat="server">
    <title> Calendar NextPrevFormat Example </title>
</head>
<body>

   <form id="form1" runat="server">

      <h3> Calendar NextPrevFormat Example </h3>

      Select a format for the next and previous month controls.

      <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="DayList"
                    AutoPostBack="True"
                    OnSelectedIndexChanged="Selection_Change"
                    runat="server">

                  <asp:ListItem Selected="True"> Custom </asp:ListItem>
                  <asp:ListItem> ShortMonth </asp:ListItem>
                  <asp:ListItem> FullMonth </asp:ListItem>

               </asp:DropDownList>

            </td>

         </tr>

      </table>

   </form>

</body>
</html>
 

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft