473,761 Members | 7,351 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to show holidays in a different color in calendar web server control?

By default, days in the calendar control are simply displayed as numbers, I
want to show some days in a different color in this control. What is the
best way to do that?

Thanks very much.

Jun 27 '08 #1
4 3008
Hi

Do subscribe the DayRender event of the calender control...
and change your style
here is a simple code snippet

protected void Calendar1_DayRe nder(object sender, DayRenderEventA rgs
e)
{
if (e.Day.IsWeeken d)
{
e.Cell.BackColo r = Color.Red;
}
}

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #2
Hi Simon,

As for Calendar control, I think the best place to perform the
customization is using "DayRender" event. In this event, you can get the
current Cell being rendered. And you can check the DateTime and then do
some customization on the cell. For example:

=============== =========
Protected Sub Calendar1_DayRe nder(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.DayR enderEventArgs) Handles Calendar1.DayRe nder

If e.Day.Date.Day Mod 5 = 1 Then

e.Cell.BackColo r = System.Drawing. Color.Yellow

End If

End Sub
=============== =========

For your case, what you need to do is write a function to check whether it
is holiday based on the DateTime value. Then, chang the background or
foreground color.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Reply-To: "Simon" <Si****@nospam. nospam>
From: "Simon" <Si****@nospam. nospam>
Subject: How to show holidays in a different color in calendar web server
control?
>Date: Thu, 19 Jun 2008 14:29:00 +0800
>
By default, days in the calendar control are simply displayed as numbers,
I
>want to show some days in a different color in this control. What is the
best way to do that?

Thanks very much.

Jun 27 '08 #3
Thank you, Steven. You are always so helpful. Thanks to Munna too.
"Steven Cheng [MSFT]" <st*****@online .microsoft.comw rote in message
news:0x******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Simon,

As for Calendar control, I think the best place to perform the
customization is using "DayRender" event. In this event, you can get the
current Cell being rendered. And you can check the DateTime and then do
some customization on the cell. For example:

=============== =========
Protected Sub Calendar1_DayRe nder(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.DayR enderEventArgs) Handles Calendar1.DayRe nder

If e.Day.Date.Day Mod 5 = 1 Then

e.Cell.BackColo r = System.Drawing. Color.Yellow

End If

End Sub
=============== =========

For your case, what you need to do is write a function to check whether it
is holiday based on the DateTime value. Then, chang the background or
foreground color.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
>>Reply-To: "Simon" <Si****@nospam. nospam>
From: "Simon" <Si****@nospam. nospam>
Subject: How to show holidays in a different color in calendar web server
control?
>>Date: Thu, 19 Jun 2008 14:29:00 +0800
>>
By default, days in the calendar control are simply displayed as numbers,
I
>>want to show some days in a different color in this control. What is the
best way to do that?

Thanks very much.

Jun 27 '08 #4
You're welcome Simon,

Have a nice day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Reply-To: "Simon" <Si****@nospam. nospam>
In-Reply-To: <0x************ **@TK2MSFTNGHUB 02.phx.gbl>
Subject: Re: How to show holidays in a different color in calendar web
server control?
>Date: Fri, 20 Jun 2008 11:28:41 +0800
>Thank you, Steven. You are always so helpful. Thanks to Munna too.
"Steven Cheng [MSFT]" <st*****@online .microsoft.comw rote in message
news:0x******* *******@TK2MSFT NGHUB02.phx.gbl ...
>Hi Simon,

As for Calendar control, I think the best place to perform the
customizatio n is using "DayRender" event. In this event, you can get the
current Cell being rendered. And you can check the DateTime and then do
some customization on the cell. For example:

============== ==========
Protected Sub Calendar1_DayRe nder(ByVal sender As Object, ByVal e As
System.Web.UI. WebControls.Day RenderEventArgs ) Handles Calendar1.DayRe nder

If e.Day.Date.Day Mod 5 = 1 Then

e.Cell.BackColo r = System.Drawing. Color.Yellow

End If

End Sub
============== ==========

For your case, what you need to do is write a function to check whether
it
>is holiday based on the DateTime value. Then, chang the background or
foreground color.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you.
Please
>feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

============== =============== =============== ======
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
>ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
>where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
>up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
============== =============== =============== ======
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
>>>Reply-To: "Simon" <Si****@nospam. nospam>
From: "Simon" <Si****@nospam. nospam>
Subject: How to show holidays in a different color in calendar web server
control?
>>>Date: Thu, 19 Jun 2008 14:29:00 +0800
>>>
By default, days in the calendar control are simply displayed as numbers,
I
>>>want to show some days in a different color in this control. What is the
best way to do that?

Thanks very much.


Jun 27 '08 #5

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

Similar topics

2
5116
by: Nils Magnus Englund | last post by:
Hi! I have a large table in SQL Server 2000 with a datetime-column 'dt'. I want to select all rows from that table, excluding days which fall on holidays or weekends. What is the best way to accomplish this? I considered creating a new table called "holidays" and then selecting all rows (sort of "where not in (select * from holidays)") , but I was looking for a better solution since that implies that I have to populate the "holidays"...
2
35468
by: Ryan | last post by:
Is there an equivalent function in SQL to the 'NETWORKDAYS(start_date,end_date,holidays)' function in Excel ? NetworkDays in Excel returns the number of whole working days between start_date and end_date. Working days exclude weekends and any dates identified in holidays. This part isn't vital but would be nice to have. The weekend stuff is more important. I realise this will most likely need to be some method I write myself (possibly...
7
2691
by: Colin Young | last post by:
I have a UserControl that contains a calendar control. The calendar is not raising events (month navigation, date selections, etc.). I've checked that the OnSelectionChanged event has a handler being registered. Is there anything else obvious or otherwise that I've missed? Is there a problem using it in a UserControl? Thanks Colin
1
2158
by: bill yeager | last post by:
I would like to place the currently selected date (retrieved from the database) on a calendar control which is embedded inside a datagrid. However, I can't find the ID of the control to do so. During the "Edit" command of the grid, I have the following code: <code> If e.CommandName = "Edit" Then Dim myDatagridItem As DataGridItem Dim lblStartDate As Label Dim lblEndDate As Label
54
2160
by: Bob | last post by:
In .NET, is there an easy way to determine State Holidays, such as Thanksgiving, Memorial day, etc? Any reference is appreciated.
6
6111
by: Sridhar | last post by:
Hi, I need to display a calendar that shows all the months of an year. In that, I need to show different colors for certain events. I know how to display a calendar for a certain month but I am not sure if there is a way to display all the months of an year? Please let me know. Thanks, Sridhar.
2
5554
by: J | last post by:
Hello. Our programmer created a VS2005 Crystal Report that uses the calendar control. It seems to work fine when viewed locally but when we publish it to the web server which is W2K Server the Calendar control's image is not showing with a red X and some text box fields look like they're enabled but can't click on to them. Does anyone know what we need to do to make the Calendar control and other text box fields work when we publish...
7
2371
by: John Kotuby | last post by:
Hi all, I am trying to use a calendar server control which I have ID="Calendar1" in the source code. What I am trying to do is emulate a JavaScript calendar that was being used in an older ASP version of the application. The javascript version worked nicely -- you click on a calendar.gif in an anchor next to a textbox. The calender would pop up in a new window, you select the date, the calendar window would close and the textbox would be...
1
2312
by: Rumple517 | last post by:
In my Access database project, I need to determine deadline dates based on working days and excluding holidays. I have set up the table as instructed below. The code that was given is for calculating the number of days between two dates. What I need is the code that will give me a date based on a date and the number of days (can vary and be either positive or negative). Can this be modified to do this? I appreciate your help. CREATE...
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9902
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8770
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.