Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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 SelectedDatesCollection SelectedDates { get; }
/** @property */
public SelectedDatesCollection get_SelectedDates ()

public function get SelectedDates () : SelectedDatesCollection

Not applicable.

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;

    // 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)
    TextView1.Text = "Selection Count ="
       + Calendar1.SelectedDates.Count.ToString();

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1

Community Additions

© 2015 Microsoft