ASPxCalendar.SelectedDates Property
Gets a collection of dates selected within the calendar.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.1.dll
NuGet Package: DevExpress.Web
Declaration
Property Value
Type | Description |
---|---|
CalendarSelection | A CalendarSelection object that represents the collection of selected dates. |
Remarks
A collection obtained via the SelectedDates property provides the means to iterate through its items (selected dates), remove specific dates from the selection or add new dates to the selection.
Example
This example demonstrates how multiple dates can be selected within the ASPxCalendar control.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register assembly="DevExpress.Web.v8.3, Version=8.3.2.0, Culture=neutral,
PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e) {
}
protected void Button1_Click(object sender, EventArgs e) {
if (Button1.Text == "Select Month") {
ASPxCalendar1.SelectedDates.Clear();
ASPxCalendar1.SelectedDates.AddRange(new DateTime(2007, 9, 1),
new DateTime(2007, 9, 30));
Button1.Text = "Clear Selection";
} else {
ASPxCalendar1.SelectedDates.Clear();
Button1.Text = "Select Month";
}
}
protected void Button2_Click(object sender, EventArgs e) {
if (Button2.Text == "Select Weekends") {
ASPxCalendar1.SelectedDates.Clear();
ASPxCalendar1.SelectedDates.Add(new DateTime[] {
new DateTime(2007, 9, 1), new DateTime(2007, 9, 2), new DateTime(2007, 9, 8),
new DateTime(2007, 9, 9), new DateTime(2007, 9, 15), new DateTime(2007, 9, 16),
new DateTime(2007, 9, 22), new DateTime(2007, 9, 23), new DateTime(2007, 9, 29),
new DateTime(2007, 9, 30)
});
Button2.Text = "Deselect Weekends";
} else {
ASPxCalendar1.SelectedDates.RemoveRange(new DateTime(2007, 9, 1),
new DateTime(2007, 9, 2));
ASPxCalendar1.SelectedDates.RemoveRange(new DateTime(2007, 9, 8),
new DateTime(2007, 9, 9));
ASPxCalendar1.SelectedDates.RemoveRange(new DateTime(2007, 9, 15),
new DateTime(2007, 9, 16));
ASPxCalendar1.SelectedDates.RemoveRange(new DateTime(2007, 9, 22),
new DateTime(2007, 9, 23));
ASPxCalendar1.SelectedDates.RemoveRange(new DateTime(2007, 9, 29),
new DateTime(2007, 9, 30));
Button2.Text = "Select Weekends";
}
}
protected void Button3_Click(object sender, EventArgs e) {
if (Button3.Text == "Select 1'st October") {
ASPxCalendar1.SelectedDates.Clear();
ASPxCalendar1.SelectedDates.Add(new DateTime(2007, 10, 1));
Button3.Text = "Deselect 1'st October";
} else {
ASPxCalendar1.SelectedDates.Remove(new DateTime(2007, 10, 1));
Button3.Text = "Select 1'st October";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Multiple Dates Selection</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br/>
<asp:Button ID="Button1" Text="Select Month" runat="server"
OnClick="Button1_Click" />
<asp:Button ID="Button2" Text="Select Weekends" runat="server"
OnClick="Button2_Click" />
<asp:Button ID="Button3" Text="Select 1'st October" runat="server"
OnClick="Button3_Click" />
<br/><br/>
<dxe:ASPxCalendar EnableMultiSelect="True" ID="ASPxCalendar1"
runat="server"
SelectedDate="09/04/2007 12:35:23">
</dxe:ASPxCalendar>
</div>
</form>
</body>
</html>
See Also