473,396 Members | 1,712 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,396 software developers and data experts.

How to call Calendar DayRender event?

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 sender,
System.Web.UI.WebControls.DayRenderEventArgs e)
{
// Display weekend dates in green boxes.
Style weekendStyle = new Style();
weekendStyle.BackColor = System.Drawing.Color.Green;
}

And I put this into InitializeComponent():
this.Calendar1.DayRender += new System.EventHandler(this.Calendar1_DayRender);

There's something I'm not doing right because I get a compile error:
....DayRenderEventArgs)' does not match delegate 'void System.EventHandler(object,
System.EventArgs)'

How does one work with the DayRender event?

Thanks for your help.
Nov 18 '05 #1
2 7530
Bruce...on the aspx on the calendar control you can add the OnDayRender and
a function name

<asp:Calendar id="Calendar1" OnDayRender="DayRender" style="Z-INDEX: 101;
LEFT: 112px; POSITION: absolute; TOP: 184px"
runat="server"></asp:Calendar>

then in your code behind you add the function

protected void DayRender(Object sender, DayRenderEventArgs e)
{
if(e.Day.IsWeekend)
{
e.Cell.BackColor = System.Drawing.Color.LightGreen;
}
}

HTH,

Jose

"Bruce W..1" <br***@noDirectEmail.com> wrote in message
news:3F***************@noDirectEmail.com...
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 sender,
System.Web.UI.WebControls.DayRenderEventArgs e)
{
// Display weekend dates in green boxes.
Style weekendStyle = new Style();
weekendStyle.BackColor = System.Drawing.Color.Green;
}

And I put this into InitializeComponent():
this.Calendar1.DayRender += new System.EventHandler(this.Calendar1_DayRender);
There's something I'm not doing right because I get a compile error:
...DayRenderEventArgs)' does not match delegate 'void System.EventHandler(object, System.EventArgs)'

How does one work with the DayRender event?

Thanks for your help.

Nov 18 '05 #2
Jose L Rodriguez wrote:

Bruce...on the aspx on the calendar control you can add the OnDayRender and
a function name

<asp:Calendar id="Calendar1" OnDayRender="DayRender" style="Z-INDEX: 101;
LEFT: 112px; POSITION: absolute; TOP: 184px"
runat="server"></asp:Calendar>

then in your code behind you add the function

protected void DayRender(Object sender, DayRenderEventArgs e)
{
if(e.Day.IsWeekend)
{
e.Cell.BackColor = System.Drawing.Color.LightGreen;
}
}

HTH,

Jose

================================================== ====

That works. I would have never figured that out. Thanks a bunch!
Nov 18 '05 #3

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...
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() {...
4
by: Kurt Schroeder | last post by:
I am trying to add a link button to a calendar. this is a simple example: Private Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles...
0
by: MattB | last post by:
Hello. I have a asp.net (1.1) application that uses the calendar control to sell event tickets. I use the DayRender event to make days selectable or not depending on the event's dates. I've found...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
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...

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.