Calendar.SelectedDates Property

Gets a collection of selected dates from the ASP.NET SelectedDatesCollection class.

Namespace: System.Web.UI.MobileControls
Assembly: System.Web.Mobile (in system.web.mobile.dll)

public:
property SelectedDatesCollection^ SelectedDates {
	SelectedDatesCollection^ get ();
}
/** @property */
public SelectedDatesCollection get_SelectedDates ()

public function get SelectedDates () : SelectedDatesCollection

Property Value

A collection of selected dates.

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

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.

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

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1

Community Additions

ADD
Show: