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
,指示日期由系统设置确定。