Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

How to: Read Selected Dates in the Calendar Web Server Control

The first example displays the currently selected day. The second example displays all selected dates, which might be a single day, a week, or a month.

// Example 1
Label1.Text = Calendar1.SelectedDate.ToShortDateString();

// Example 2
String s = "";
foreach(DateTime d in Calendar1.SelectedDates)
{
    s += "<br />" + d.ToShortDateString();
}
Label1.Text = s;

This example requires:

  • A Web Forms page.

  • A Calendar control named Calendar1.

  • A Label control named Label1.

If only one day is selected, the SelectedDates property will get just one date. If a week or a month is selected, the SelectedDate property will get the first date from that collection.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.