Share via


SelectedDate Property

Sets or returns the currently selected date. Has the same functionality as the ASP.NET Calendar.SelectedDate property. The default value is the value of System.DateTime.MinValue.

public DateTime SelectedDate {
   get,
   set
}

Remarks

Typically, you use this property together with the SelectionMode property to determine the selected date of a Calendar control. To do this, set the SelectionMode property to Day — this setting allows only a single date selection from the Calendar control.

Browsing to the next or previous month will not update this property.

Example

The following example demonstrates how to use the SelectedDate property to refer to the selected day.

Protected Sub Calendar_SelectionChanged(sender As [Object], e As EventArgs)
   Label1.Text = "The date you selected is " + calendar1.SelectedDate.ToShortDateString()
End Sub

[C#]

protected void Calendar_SelectionChanged(Object sender, EventArgs e)
{
    Label1.Text = "The date you selected is " + 
                 calendar1.SelectedDate.ToShortDateString();
}

<mobile:Form id="Form1" runat=server>
  <mobile:calendar id="calendar1" 
    OnSelectionChanged="Calendar_SelectionChanged" runat="server" />
</mobile:Form>

See Also

Applies to: Calendar Class