Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Experts,

I have a code like below which I am highliting Interview in my calender for the Date 2012/05/03.

My problem is, I have to highlight a range of date like 2012/05/03-2012/05/15, how can I do it?

C#
var ce = new CustomEvent();
ce.IgnoreTimeComponent = false;
ce.EventText = "Interview";
ce.Date = new DateTime(2012, 5, 3);
Posted
Comments
Christian Amado 24-Jul-14 8:17am    
ASP.NET,Winforms, WPF, Silverlight? What kind of project are you using?
abdulsafran 24-Jul-14 8:39am    
C# Windows Form Application

1 solution

If you are using asp calender control then

By using ondayrender property we can highlight particular dates(by changing background/fore color)


in.aspx page
XML
<asp:Calendar ID="Calendar1" runat="server" ondayrender="MyDayRenderer">

in aspx.cs page

<pre lang="cs">protected void MyDayRenderer(object sender, DayRenderEventArgs e)
    {
        if (e.Day.IsToday)
        {
            e.Cell.BackColor = System.Drawing.Color.Aqua;
        }

        if (e.Day.Date == new DateTime(2011,5,1))
        {
            e.Cell.BackColor = System.Drawing.Color.Beige;
        }
    }</pre>
 
Share this answer
 
Comments
abdulsafran 24-Jul-14 8:40am    
Thanks for the answer, but I'm not using ASP.Net, only using C#. Please help me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900