NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Responding to Date Selection

If the Calendar Web control's SelectionMode is set to anything other than None, the user can select a day or a range of dates. You can detect and respond to the user's choice.

To respond to a date selection

Information about date selection is available in these properties:

To determine how many dates are selected

If you've determined that the user has selected multiple dates, you can get the range.

To get the date range of a multi-date selection

  1. Get the count of selected dates using the Count property of the SelectedDates property.
  2. Get the first date in the collection, and then get the last date by extracting the date at the index of the count -1. The following example displays the first and last dates in TextBox controls on the page.
    [Visual Basic]
    Public Sub Calendar1_OnSelectionChanged ( s As Object, _
           e As DayRenderEvent)
       If Calendar1.SelectedDates.Count > 1 Then
          Dim FirstDate as DateTime
          Dim LastDate as DateTime
          FirstDate = SelectedDates[0]
          LastDate = SelectedDates[SelectedDates.Count - 1]
          txtFirstDate.Text = FirstDate.toString
          txtLastDate.Text = LastDate.toString
       End If
    End Sub
    

To get the time span of a multi-date selection

See Also

Using the Calendar Web Control