Calendar.DayNameFormat 屬性

定義

取得或設定星期的名稱格式。

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

屬性值

其中一個 DayNameFormat 值。 預設值是 Short

屬性

例外狀況

指定的日期名稱格式不是其中一個 DayNameFormat 值。

範例

下列程式碼範例示範如何使用 DayNameFormat 屬性來指定一周中的天數以完整顯示。

<%@ 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"
           ShowDayHeader="True"
           DayNameFormat="Full"/>
            
   </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"
           ShowDayHeader="True"
           DayNameFormat="Full"/>
            
   </form>
        

</body>
</html>
<%@ Page Language="C#"%>

<!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 runat="server">
    <title> Calendar DayNameFormat Example </title>
</head>
<body>
   <form id="form1" runat="server">
  
     <h3> Calendar DayNameFormat Example </h3>

     <asp:Calendar id="Calendar1"
       daynameformat="Shortest"
       runat="server"/>
       
    </form>
  </body>
</html>
<%@ Page Language="VB"%>

<!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 runat="server">
    <title> Calendar DayNameFormat Example </title>
</head>
<body>
   <form id="form1" runat="server">
  
     <h3> Calendar DayNameFormat Example </h3>

     <asp:Calendar id="Calendar1"
       daynameformat="Shortest"
       runat="server"/>
       
    </form>
  </body>
</html>

備註

DayNameFormat使用 屬性來指定星期幾的名稱格式。 這個屬性是使用其中 DayNameFormat 一個列舉值來設定。 您可以指定星期幾是否顯示為完整名稱、簡短 (縮寫) 名稱、日的第一個字母,或當天的前兩個字母。

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

日期名稱是以伺服器的本機設定為基礎。

適用於

另請參閱