[转]Calendar 控件日期复选
Calendar 控件可以透过 SelectedDate 属性来取目前选取的日期,不过它没有提供日期复选的功能。为达到日期复选的功能,我们在 DayRender 事件中,为每一个日期储存格加入一个 HtmlInputCheckBox 控件做日期选取,当 PostBack 时再透过 Request.Form 来取得客户端复选的日期。
Partial Class _Default
Inherits System.Web.UI.Page
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
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()
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
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
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
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 三个日期。
![](http://files.dotblogs.com.tw/jeff377/0806/Calendar_12FCE/image_thumb.png)
当按下按钮产生 PostBack 时,透过 Request.Form 即可取得复选的日期。
![](http://files.dotblogs.com.tw/jeff377/0806/Calendar_12FCE/image_thumb_1.png)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
执行程序,勾选了6/2、6/10、6/18 三个日期。
![](http://files.dotblogs.com.tw/jeff377/0806/Calendar_12FCE/image_thumb.png)
当按下按钮产生 PostBack 时,透过 Request.Form 即可取得复选的日期。
![](http://files.dotblogs.com.tw/jeff377/0806/Calendar_12FCE/image_thumb_1.png)