Calendar.SelectedDates Propriété

Définition

Obtient une collection de dates sélectionnées à partir de la classe SelectedDatesCollection ASP.NET.Gets a collection of selected dates from the ASP.NET SelectedDatesCollection class. Cette API est obsolète.This API is obsolete. Pour plus d’informations sur le développement d’applications mobiles ASP.NET, consultez Applications mobiles& sites avec ASP.NET.For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with 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

Valeur de propriété

SelectedDatesCollection

Collection de dates sélectionnées.A collection of selected dates.

Attributs

Exemples

L’exemple de code suivant montre comment utiliser la SelectedDates propriété pour sélectionner tous les mercredis du mois en cours.The following code example demonstrates how to use the SelectedDates property to select all the Wednesdays in the current month. Cet exemple fait partie d’un exemple de code plus large pour la Calendar vue d’ensemble.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();
}
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

Remarques

Cette propriété représente une collection de dates sélectionnées dans un Calendar contrôle.This property represents a collection of selected dates in a Calendar control.

S’applique à