技术开发 频道

Calendar 控件日期复选


【IT168技术文档】

  Calendar 控件可以透过 SelectedDate 属性来取目前选取的日期,不过它没有提供日期复选的功能。为达到日期复选的功能,我们在 DayRender 事件中,为每一个日期储存格加入一个 HtmlInputCheckBox 控件做日期选取,当 PostBack 时再透过 Request.Form 来取得客户端复选的日期。
Partial Class _DefaultClass _Default Inherits System.Web.UI.Page Protected Sub Calendar1_DayRender()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()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 即可取得复选的日期。
0
相关文章