ASP.NET SelectedDates 属性

定义和用法

SelectedDates 属性用于设置或返回日历中被选的日期。

实例

下面的例子在某日期被选择时输出该被选日期:

  1. <script language="VB" runat="server">
  2. Sub Change(obj As Object, e As EventArgs)
  3. Dim i As Integer
  4. For i = 0 To Cal1.SelectedDates.Count - 1
  5. Response.Write(Cal1.SelectedDates(i).ToShortDateString())
  6. Response.Write("<br />")
  7. Next i
  8. End Sub
  9. </script>
  10.  
  11. <form runat="server">
  12. <asp:Calendar id="cal1" runat="server"
  13. SelectionMode="DayWeekMonth"
  14. OnSelectionChanged="Change" />
  15. </form>

实例

  • 设置 Calendar 控件的 SelectedDates