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.

[Visual Basic]
Public Property NextPrevFormat As NextPrevFormat
[C#]
public NextPrevFormat NextPrevFormat {get; set;}
[C++]
public: __property NextPrevFormat get_NextPrevFormat();
public: __property void set_NextPrevFormat(NextPrevFormat);
[JScript]
public function get NextPrevFormat() : NextPrevFormat;
public function set NextPrevFormat(NextPrevFormat);

Property Value

One of the NextPrevFormat values. The default value is CustomText.

Exceptions

Exception Type Condition
ArgumentException The specified format is not one of the NextPrevFormat values.

Remarks

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 only applies if the ShowNextPrevMonth property is set to true.

Example

[Visual Basic, C#, JScript] The following example demonstrates how to use the NextPrevFormat property to specify the short month format for the navigation controls.

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

</head>
<body>

   <form runat="server">

      <h3>Calendar Example</h3>

      <asp:Calendar id="calendar1" runat="server"
           ShowNextPrev="True"
           NextPrevFormat="ShortMonth"/>
            
   </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"
           ShowNextPrev="True"
           NextPrevFormat="ShortMonth"/>
            
   </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"
           ShowNextPrev="True"
           NextPrevFormat="ShortMonth"/>
            
   </form>
        

</body>
</html>


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

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

         ' Set the format for the next and previous month controls.
         Calendar1.NextPrevFormat = _
            CType(DayList.SelectedIndex, NextPrevFormat)

      End Sub
  
   </script>
  
<body>

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

</body>
</html>
 

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

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

   <form 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>
  
   </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 | NextPrevFormat | NextMonthText | PrevMonthText

Show:
© 2014 Microsoft