Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
Dim oCheckBox As New HtmlControls.HtmlInputCheckBox()
oCheckBox.Value = e.Day.Date.ToShortDateString
oCheckBox.ID = "SelectDate"
e.Cell.Controls.Clear()
e.Cell.Controls.Add(oCheckBox)
e.Cell.Controls.Add(New LiteralControl(e.Day.DayNumberText))
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Response.Write("SelectDate: " & Me.Request.Form("SelectDate"))
End Sub
End Class
Inherits System.Web.UI.Page
Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
Dim oCheckBox As New HtmlControls.HtmlInputCheckBox()
oCheckBox.Value = e.Day.Date.ToShortDateString
oCheckBox.ID = "SelectDate"
e.Cell.Controls.Clear()
e.Cell.Controls.Add(oCheckBox)
e.Cell.Controls.Add(New LiteralControl(e.Day.DayNumberText))
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Response.Write("SelectDate: " & Me.Request.Form("SelectDate"))
End Sub
End Class
执行程序,勾选了6/2、6/10、6/18 三个日期。
当按下按钮产生 PostBack 时,透过 Request.Form 即可取得复选的日期。