Question about Calendar Control

kpao

Active member
Joined
Apr 3, 2006
Messages
29
Programming Experience
Beginner
Is there any way to implement multiple selection in Calendar Control?
Can anybody post me the link about calendar mulitple selection. Thanks you:) :)
 
Add a calendar to a webform and this code behind:
VB.NET:
Dim caldays As ArrayList
 
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
  caldays = Cache("caldays")
  If caldays Is Nothing Then caldays = New ArrayList
End Sub
 
Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Calendar1.SelectionChanged
  If caldays.Contains(Calendar1.SelectedDate) = False Then
    caldays.Add(Calendar1.SelectedDate)
    Cache("caldays") = caldays
  End If
End Sub
 
Private Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) _
Handles Calendar1.DayRender
  If caldays.Contains(e.Day.Date) = True Then
    e.Cell.BackColor = Color.LightGreen
  End If
End Sub
Each time you click a new date it will add to list of selected dates (caldays ArrayList). All selected dates is painted with LightGreen backcolor in DayRender event. The ArrayList is cached between postbacks. Add a button to reset the list or something.
 
Back
Top