Calendar.NextPrevFormat 屬性

定義

取得或設定在 Calendar 控制項的標題區段中往上和往下月份巡覽項目的格式。

public:
 property System::Web::UI::WebControls::NextPrevFormat NextPrevFormat { System::Web::UI::WebControls::NextPrevFormat get(); void set(System::Web::UI::WebControls::NextPrevFormat value); };
[System.ComponentModel.Bindable(true)]
public System.Web.UI.WebControls.NextPrevFormat NextPrevFormat { get; set; }
public System.Web.UI.WebControls.NextPrevFormat NextPrevFormat { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.NextPrevFormat : System.Web.UI.WebControls.NextPrevFormat with get, set
member this.NextPrevFormat : System.Web.UI.WebControls.NextPrevFormat with get, set
Public Property NextPrevFormat As NextPrevFormat

屬性值

NextPrevFormat

其中一個 NextPrevFormat 值。 預設值是 CustomText

屬性

例外狀況

指定的格式不是其中一個 NextPrevFormat 值。

範例

下列程式碼範例示範如何使用 NextPrevFormat 屬性來指定導覽控制項的簡短月份格式。

<%@ 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="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" >
<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>
<%@ 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 format for the next and previous month controls.
         Calendar1.NextPrevFormat = _
            CType(DayList.SelectedIndex, NextPrevFormat)

      End Sub
  
   </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>

備註

NextPrevFormat使用 屬性可指定 控制項上 Calendar 下一個和上一個月導覽元素的格式。 這個屬性是使用其中 NextPrevFormat 一個列舉值來設定。 您可以指定導覽控制項的文字是否顯示為完整月份名稱、簡短 (縮寫) 月份名稱或自訂文字。

若要指定自訂導覽文字,請將此屬性設定為 NextPrevFormat.CustomText ,並將 和 PrevMonthText 屬性設定 NextMonthText 為自訂文字。

只有當 屬性設定為 true 時, ShowNextPrevMonth 才會套用這個屬性。

適用於

另請參閱