Calendar.SelectedDates 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取 ASP.NET SelectedDatesCollection 类中选定日期的集合。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站。
public:
property System::Web::UI::WebControls::SelectedDatesCollection ^ SelectedDates { System::Web::UI::WebControls::SelectedDatesCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.UI.WebControls.SelectedDatesCollection SelectedDates { get; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectedDates : System.Web.UI.WebControls.SelectedDatesCollection
Public ReadOnly Property SelectedDates As SelectedDatesCollection
属性值
选定日期的集合。
- 属性
示例
下面的代码示例演示如何使用 SelectedDates 属性选择当月的所有星期三。 此示例是概述的较大代码示例的 Calendar 一部分。
protected void Command1_Click(object sender, EventArgs e)
{
int currentDay = Calendar1.VisibleDate.Day;
int currentMonth = Calendar1.VisibleDate.Month;
int currentYear = Calendar1.VisibleDate.Year;
Calendar1.SelectedDates.Clear();
// Add all Wednesdays to the collection.
for (int i = 1; i <= System.DateTime.DaysInMonth(currentYear,
currentMonth); i++)
{
DateTime targetDate = new DateTime(currentYear, currentMonth, i);
if (targetDate.DayOfWeek == DayOfWeek.Wednesday)
Calendar1.SelectedDates.Add(targetDate);
}
TextView1.Text = "Selection Count ="
+ Calendar1.SelectedDates.Count.ToString();
}
Protected Sub Command1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim currentDay As Integer = Calendar1.VisibleDate.Day
Dim currentMonth As Integer = Calendar1.VisibleDate.Month
Dim currentYear As Integer = Calendar1.VisibleDate.Year
Calendar1.SelectedDates.Clear()
' Loop through current month and add all Wednesdays to the collection.
Dim i As Integer
For i = 1 To System.DateTime.DaysInMonth(currentYear, currentMonth)
Dim targetDate As New DateTime(currentYear, currentMonth, i)
If targetDate.DayOfWeek = DayOfWeek.Wednesday Then
Calendar1.SelectedDates.Add(targetDate)
End If
Next i
TextView1.Text = "Selection Count = " & Calendar1.SelectedDates.Count.ToString()
End Sub
注解
此属性表示控件中 Calendar 所选日期的集合。