Private Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
Dim onmouseoverStyle As String = "this.style.backgroundColor='#D4EDFF'"
Dim onmouseoutStyle As String = "this.style.backgroundColor='@BackColor'"
Dim rowBackColor As String = String.Empty
Dim ExistingCellColour As System.Drawing.Color
Dim newBackColor as String = ""
ExistingCellColour = e.Cell.BackColor
'MsgBox(ExistingCellColour.ToString)
'Set your day's back color first.
'If the month is CurrentMonth
If Not e.Day.IsOtherMonth Then
Dim dr As DataRow
For Each dr In ds.Tables(0).Rows
'If EventDate is not Null
If Not dr("ONDATE") Is DBNull.Value Then
Dim dtEvent As DateTime = dr("ONDATE").ToString
'If EventDate =CalendarDate
If dtEvent.Equals(e.Day.Date) Then
e.Cell.BackColor = Color.PaleVioletRed
newBackColor = e.Cell.BackColor
End If
End If
Next
'If the month is not CurrentMonth then hide the Dates
Else
e.Cell.Text = ""
End If
'Now set your mouseover colors
If Not e.Day.IsWeekend Then
e.Cell.Attributes.Add("onmouseover", onmouseoverStyle)
if newBackColor = "" then
e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor))
else e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", newBackColor))
end if
End If
e.Cell.Attributes.Add("onmouseover", onmouseoverStyle)
if newBackColor = "" then
e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor))
else
e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", newBackColor))
end if
End Sub