Calendar control OnDayRender() method

T

tom c

I have an ASP.Net app that uses the calendar control to select a report
for a particular date. Reports exist for most dates, but not all, so I
would like to highlight the dates for which the reports exist. I asked
about this a while back and was told to use the Calendar.OnDayRender()
method. I am reading about this and getting totally confuesd.

Here is the microsoft documentation http://tinyurl.com/nd4od

I am using ASP.Net 1.1 with VB and using the IDE

First they show this code:

Protected Overridable Sub OnDayRender( _
ByVal cell As TableCell, _
ByVal day As CalendarDay _
)

Is that something I add to my code, or something that is already there?
If I need to add it to my code, where does it go?

Then they show the code below which doesn't look like anything I am
used to seeing in the IDE. I don't understand the html tags around the
VB code. Where does this code go if I am using the IDE?

<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>
<script language="VB" runat="server">
Sub DayRender(source As Object, e As DayRenderEventArgs)
' Change the background color of the days in the month
' to yellow.
If Not e.Day.IsOtherMonth And Not e.Day.IsWeekend Then
e.Cell.BackColor = System.Drawing.Color.Yellow
End If
' Add custom text to cell in the Calendar control.
If e.Day.Date.Day = 18 Then
e.Cell.Controls.Add(New LiteralControl(ChrW(60) & "br"
& ChrW(62) & "Holiday"))
End If
End Sub 'DayRender
</script>
</head>
<body>

<form runat="server">

<h3>DayRender Event Example</h3>

<asp:Calendar id="calendar1"
OnDayRender="DayRender"
runat="server">

<WeekendDayStyle BackColor="gray">
</WeekendDayStyle>

</asp:Calendar>

</form>

</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top