473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

calendar dayrender event...

RAB
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

Mar 4 '07 #1
1 4265
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

Mar 4 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: CodeRazor | last post by:
Hi, I have been using the DayRender event of the calendar control to format the appearance of my calendar control, and it works ok. However, because of the way the DayRender event works, it...
3
by: CodeRazor | last post by:
Hi, I have been using the DayRender event of the calendar control to format the appearance of my calendar control, and it works ok. However, because of the way the DayRender event works, it...
6
by: Jeff S | last post by:
I would like recommendations for implementing a calendar in an ASP.NET web site. My plan is to store date and event information (e.g,, "Spring Sale") in a database, and when the page is requested,...
2
by: Bruce W..1 | last post by:
I want to change the display style of certain days in my Calendar control. This is done with the DayRender event. So I put this in the codebehind: private void Calendar1_DayRender (object...
2
by: VB Programmer | last post by:
How can I force the DayRender event of my Calendar to run/refresh? The calendar displays data from a database and I am allowing the user to filter out what data they see on the calendar. When...
2
by: Trond | last post by:
I'm having a problem when creating several calendars in a web form. Here's a snippet of my code: ****************************** public string username; private void CreateCalendars() {...
2
by: serge calderara | last post by:
Dear all, I have a webform with a calendar control on it. When loaded the calendar is set to the current date. Depending on a criteria from a database field, calendar day cell appears with red...
3
by: Paul | last post by:
Hi, I have a calendar control for a .net web application and was wondering if it is possible to change the appearance of some of these days when the page loads? The application loads date...
1
by: Dabbler | last post by:
I'm trying to customize calendar days using data in a table. Some days may have corresponding rows in the table giving counts for that day. I'm not clear on when I should get the data from the...
0
by: tom c | last post by:
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.