Calendar control: on day render (VB.net) : Calendar « Asp Control « ASP.Net






Calendar control: on day render (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub DateDisplayed(source As Object, e As DayRenderEventArgs)
    If e.Day.Date.Month = "2" and e.Day.Date.Day = "14" Then
        e.Cell.BackColor = System.Drawing.Color.Red
        e.Cell.ForeColor = System.Drawing.Color.Yellow
    ElseIf e.Day.Date.Month = "12" and e.Day.Date.Day = "25" Then
        e.Cell.BackColor = System.Drawing.Color.Green
        e.Cell.ForeColor = System.Drawing.Color.Red
    ElseIf e.Day.Date.Month = "10" and e.Day.Date.Day = "31" Then
        e.Cell.BackColor = System.Drawing.Color.Orange
        e.Cell.ForeColor = System.Drawing.Color.Black
    End If
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Controlling the Appearance of Individual Cells of Dates in the Calendar Control</TITLE>
</HEAD>
<BODY LEFTMARGIN="40">
<form runat="server">
Select a Date
<BR><BR>
<asp:Calendar 
    id="Mycal" 
    runat="server"
    cellpadding="3"
    cellspacing="3"
    ondayrender="DateDisplayed"
/>
</form>
</BODY>
</HTML>
           
       








Related examples in the same category

1.Change Calendar selection based on data from the database (VB.net)
2.Calendar selected value changed event (VB.net)
3.Assign today's date to asp calendar (VB.net)
4.Set asp calendar border (VB.net)
5.Calendar Control: day name format, first day of week (VB.net)
6.Calendar Control: nextprevformat (VB.net)
7.Calendar Control: titleformat (VB.net)
8.Controlling the Appearance of Individual Cells of Dates (VB.net)
9.Formatting Date Sections in a Calendar Control (VB.net)
10.Date Selection event in a Calendar Control (VB.net)
11.Formatting the Header Styles in a Calendar Control (VB.net)
12.On visible month changed event for a calendar control (VB.net)
13.Setting Custom Previous and Next Month Text in the Calendar Control (VB.net)
14.Reading Selected Dates in a Date Range through the Calendar Control (VB.net)
15.Allowing the Selection of Multiple Dates in a Calendar Control (VB.net)
16.Displaying a Date in the Calendar Control (VB.net)
17.Displaying a Selected Range of Dates in the Calendar Control (VB.net)
18.Basic Calendar Control: show grid lines, show day header (VB.net)
19.On Date and Month Selection Changed (VB.net)
20.Select a week (VB.net)
21.Convert selected date from asp:Calendar to long string (VB.net)
22.Selected value change envent for asp:Calendar (VB.net)
23.Get selected date from asp:Calendar (VB.net)
24.Calendar with TodayDayStyle, SelectorStyle, NextPrevStyle, and SelectedDayStyle (C#)
25.Calendar control in code behind (C#)
26.Load event in calendar selection event (C#)
27.Define and use calendar in code behind (C#)
28.Embed Javascript to C# code to create a popup window
29.Popup calendar
30.Calendar events: render and change events
31.Visible month changed event
32.Day renderer
33.Calendar selection changed event
34.Calendar selection mode: DayWeekMonth
35.Calendar selection mode: Day
36.Calendar selection mode: DayWeek
37.Add control to Calendar cell
38.Set TodayDayStyle: background color and foreground color
39.Set DayStyle, NextPrevStyle, DayHeaderStyle, TitleStyle, WeekendDayStyle
40.Change size of Calendar
41.Check the range of Calendar controls