Calendar.FirstDayOfWeek 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定星期,其將顯示於 Calendar 控制項的第一個日期欄位。
public:
property System::Web::UI::WebControls::FirstDayOfWeek FirstDayOfWeek { System::Web::UI::WebControls::FirstDayOfWeek get(); void set(System::Web::UI::WebControls::FirstDayOfWeek value); };
[System.ComponentModel.Bindable(true)]
public System.Web.UI.WebControls.FirstDayOfWeek FirstDayOfWeek { get; set; }
public System.Web.UI.WebControls.FirstDayOfWeek FirstDayOfWeek { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.FirstDayOfWeek : System.Web.UI.WebControls.FirstDayOfWeek with get, set
member this.FirstDayOfWeek : System.Web.UI.WebControls.FirstDayOfWeek with get, set
Public Property FirstDayOfWeek As FirstDayOfWeek
屬性值
其中一個 FirstDayOfWeek 值。 預設值為 Default
,指出使用系統設定值所指定的日期。
- 屬性
例外狀況
指定的日期不是其中一個 FirstDayOfWeek 值。
範例
下列程式碼範例示範如何使用 FirstDayOfWeek 屬性將第一天資料行設定為星期一。
<%@ 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"
FirstDayOfWeek="Monday"/>
</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"
FirstDayOfWeek="Monday"/>
</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 first day of the week.
Calendar1.FirstDayOfWeek = (FirstDayOfWeek)DayList.SelectedIndex;
}
</script>
<head runat="server">
<title> Calendar FirstDayOfWeek Example </title>
</head>
<body>
<form id="form1" runat="server">
<h3> Calendar FirstDayOfWeek Example </h3>
Select the first day of the week.
<br /><br />
<asp:Calendar id="Calendar1"
ShowGridLines="True"
ShowTitle="True"
runat="server"/>
<br /><br />
<table cellpadding="5">
<tr>
<td>
First day of the week:
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="DayList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem> Sunday </asp:ListItem>
<asp:ListItem> Monday </asp:ListItem>
<asp:ListItem> Tuesday </asp:ListItem>
<asp:ListItem> Wednesday </asp:ListItem>
<asp:ListItem> Thursday </asp:ListItem>
<asp:ListItem> Friday </asp:ListItem>
<asp:ListItem> Saturday </asp:ListItem>
<asp:ListItem Selected="True"> Default </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 first day of the week.
Calendar1.FirstDayOfWeek = CType(DayList.SelectedIndex, _
System.Web.UI.WebControls.FirstDayOfWeek)
End Sub
</script>
<head runat="server">
<title> Calendar FirstDayOfWeek Example </title>
</head>
<body>
<form id="form1" runat="server">
<h3> Calendar FirstDayOfWeek Example </h3>
Select the first day of the week.
<br /><br />
<asp:Calendar id="Calendar1"
ShowGridLines="True"
ShowTitle="True"
runat="server"/>
<br /><br />
<table cellpadding="5">
<tr>
<td>
First day of the week:
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="DayList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem> Sunday </asp:ListItem>
<asp:ListItem> Monday </asp:ListItem>
<asp:ListItem> Tuesday </asp:ListItem>
<asp:ListItem> Wednesday </asp:ListItem>
<asp:ListItem> Thursday </asp:ListItem>
<asp:ListItem> Friday </asp:ListItem>
<asp:ListItem> Saturday </asp:ListItem>
<asp:ListItem Selected="True"> Default </asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</form>
</body>
</html>
備註
FirstDayOfWeek使用 屬性可指定在 控制項的第一天資料行 Calendar 中顯示的星期數。 這個屬性是使用其中 FirstDayOfWeek 一個列舉值來設定。 您可以指定一周或 FirstDayOfWeek.Default
的任何一天,這表示日期是由系統設定決定。