How to call Calendar DayRender event?

B

Bruce W..1

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.
 
J

Jose L Rodriguez

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
 
B

Bruce W..1

Jose said:
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!
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top