How to call Calendar DayRender event?

  • Thread starter Thread starter Bruce W..1
  • Start date Start date
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.
 
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
 
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!
 
Back
Top