Howdy,
Easy resolution would be to change the way you key the dates before adding
the hashtable:
Private dateList As New System.Collections.Hashtable()
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
dateList.Add(GetHistoricalDateKey( _
New DateTime(1995, 3, 13)), Nothing)
dateList.Add(GetHistoricalDateKey(_
New DateTime(1997, 3, 19)), Nothing)
dateList.Add(GetHistoricalDateKey(_
New DateTime(1997, 4, 14)), Nothing)
End Sub
Private Function GetHistoricalDateKey( _
ByVal [date] As DateTime) As String
Return [date].Month & [date].Day
End Function
Protected Sub Calendar1_DayRender(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) _
Handles Calendar1.DayRender
If dateList.Contains(GetHistoricalDateKey(e.Day.Date) ) Then
e.Cell.Style.Add( _
HtmlTextWriterStyle.BackgroundColor, "red")
Else
e.Cell.Style.Add( _
HtmlTextWriterStyle.BackgroundColor, "whitesmoke")
End If
End Sub
Hope this helps
--
Milosz
"RAB" wrote:
I want to highlight my calendar control based on the following code:
Public Datelist as new System.Collections.Hashtable()
'DateList is filled with important dates from history
Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs)
If Not DateList(e.day.date) is Nothing then
e.cell.style.add("font-weight", "bold")
e.cell.style.add("font-size", "larger")
e.cell.style.add("border", "3 dotted darkred")
e.cell.style.add("background", "#f0f0f0")
Else
e.cell.style.add("font-weight", "lighter")
e.cell.style.add("color", "DimGray")
End If
End Sub
I want the calender control day to be highlighted if the day and month
of the calendar control match an important date in history
irrespective of the year. (ie March 3 would be highlighted on the
calendar control if the DateList contained a date such as March 3,
1776). Anyone know how I could change my code to accomplish this?
Thanks,
RABMissouri2007