Calendar.SelectedDates Property

Definition

Gets a collection of selected dates from the ASP.NET SelectedDatesCollection class. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

C#
[System.ComponentModel.Browsable(false)]
public System.Web.UI.WebControls.SelectedDatesCollection SelectedDates { get; }

Property Value

A collection of selected dates.

Attributes

Examples

The following code example demonstrates how to use the SelectedDates property to select all the Wednesdays in the current month. This example is part of a larger code sample for the Calendar overview.

C#
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();
}

Remarks

This property represents a collection of selected dates in a Calendar control.

Applies to

Proizvod Verzije
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also