V
valeria.audivert
I'm trying to implement a Calendar control using the OnDayRender to get
event information from an XML file. For the days that have special
events, I'd like to make the day bold red and show a tooltip with the
event descriptio nwhen the mouse is over that day.
I was able to do the color and font change for the event days, but I
cannot get the tooltip to work. For some reason the stadard calendar
tooltip with the date still shows.
Can anyone please help?
Please see code below:
------------------------------------------------------------------------
<asp:calendar id="Calendar1" runat="server" BackColor="Bisque"
SelectedDate="<%#DateTime.Today%
DayNameFormat="FirstLetter" font-size="11px"
font-names="tahoma"
selecteddaystyle-backcolor="silver"
style="border-color:#D7D7E5;" width="140"
PrevMonthText="<img src=images/cal_prevMonth.gif
border=0>"
NextMonthText="<img src=images/cal_nextMonth.gif
border=0>">
<TitleStyle BackColor="#D7D7E5"></TitleStyle>
<SelectedDayStyle BackColor="#FBE694"
ForeColor="#000000"
BorderWidth="1px" BorderColor="#BB5503">
</SelectedDayStyle>
<DayHeaderStyle Font-Bold="True"></DayHeaderStyle>
<OtherMonthDayStyle
ForeColor="#999999"></OtherMonthDayStyle>
</asp:calendar>
<script language="VB" runat="server">
Private monthDoc As System.Xml.XmlDocument = New
System.Xml.XmlDocument()
Public Sub calndr_DayRender(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DayRenderEventArgs)
monthDoc.Load(Server.MapPath("dayRenderData.xml"))
If e.Day.IsOtherMonth Then
Exit Sub
End If
Dim dayNumber As String = e.Day.DayNumberText
Dim dayNode As System.Xml.XmlNode = _
monthDoc.SelectSingleNode("/months/month[@index=0" & _
"]/day[@number=" & dayNumber & "]")
If Not dayNode Is Nothing Then
Dim dayItems As System.Xml.XmlNodeList =
dayNode.SelectNodes("item")
For Each dayItem As System.Xml.XmlNode In dayItems
e.Cell.Font.Bold = True
e.Cell.ForeColor = Drawing.Color.Red
e.Cell.ToolTip = dayItem.InnerXml 'THIS LINE
DOESN'T WORK
Next dayItem
End If
End Sub
</script>
event information from an XML file. For the days that have special
events, I'd like to make the day bold red and show a tooltip with the
event descriptio nwhen the mouse is over that day.
I was able to do the color and font change for the event days, but I
cannot get the tooltip to work. For some reason the stadard calendar
tooltip with the date still shows.
Can anyone please help?
Please see code below:
------------------------------------------------------------------------
<asp:calendar id="Calendar1" runat="server" BackColor="Bisque"
SelectedDate="<%#DateTime.Today%
DayNameFormat="FirstLetter" font-size="11px"
font-names="tahoma"
selecteddaystyle-backcolor="silver"
style="border-color:#D7D7E5;" width="140"
PrevMonthText="<img src=images/cal_prevMonth.gif
border=0>"
NextMonthText="<img src=images/cal_nextMonth.gif
border=0>">
<TitleStyle BackColor="#D7D7E5"></TitleStyle>
<SelectedDayStyle BackColor="#FBE694"
ForeColor="#000000"
BorderWidth="1px" BorderColor="#BB5503">
</SelectedDayStyle>
<DayHeaderStyle Font-Bold="True"></DayHeaderStyle>
<OtherMonthDayStyle
ForeColor="#999999"></OtherMonthDayStyle>
</asp:calendar>
<script language="VB" runat="server">
Private monthDoc As System.Xml.XmlDocument = New
System.Xml.XmlDocument()
Public Sub calndr_DayRender(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DayRenderEventArgs)
monthDoc.Load(Server.MapPath("dayRenderData.xml"))
If e.Day.IsOtherMonth Then
Exit Sub
End If
Dim dayNumber As String = e.Day.DayNumberText
Dim dayNode As System.Xml.XmlNode = _
monthDoc.SelectSingleNode("/months/month[@index=0" & _
"]/day[@number=" & dayNumber & "]")
If Not dayNode Is Nothing Then
Dim dayItems As System.Xml.XmlNodeList =
dayNode.SelectNodes("item")
For Each dayItem As System.Xml.XmlNode In dayItems
e.Cell.Font.Bold = True
e.Cell.ForeColor = Drawing.Color.Red
e.Cell.ToolTip = dayItem.InnerXml 'THIS LINE
DOESN'T WORK
Next dayItem
End If
End Sub
</script>