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
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

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
Dim s As String = ""
Dim d As DateTime
For Each d In Calendar1.SelectedDates
    s &= "<br />" & d.ToShortDateString()
Label1.Text = s

Compiling the Code

This example requires:

  • A Web Forms page.

  • A Calendar control named Calendar1.

  • A Label control named Label1.

Robust Programming

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.

See Also

Community Additions

© 2015 Microsoft