?
Solved

Displaying Multi date events in calendar control

Posted on 2011-02-22
5
Medium Priority
?
856 Views
Last Modified: 2012-05-11
Hi,

I am using calendar control which has a property of Dayfield to display the events in calendar. I am currently associating this dayfield property to database column field "EventStartDate" and I have another field name "EventEndDate". So earlier we need to display the events based on start date but now some of the events are spanning for months and needs to be render in the calendar since it reaches the end date. The values of eventstart and end date is specified by the user while creating events.

Is there any way that i can configure the Dayfield property to display all the dates between EventStartDate and  EventEndDate?? or there is any other way to configure asp calendar contol to achieve the same result??

Thanks in Advance!!
0
Comment
Question by:InorbitalWeb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34960375
I believe that you can achieve the effect that you need by handling the DayRender event.

Example:

Calendar.DayRender Event
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.calendar.dayrender.aspx

<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>DayRender Event Example</title>
<script language="C#" runat="server">

      void DayRender(Object source, DayRenderEventArgs e) 
      {

         // Change the background color of the days in the month
         // to yellow.
         if (!e.Day.IsOtherMonth && !e.Day.IsWeekend)
            e.Cell.BackColor=System.Drawing.Color.Yellow;

         // Add custom text to cell in the Calendar control.
         if (e.Day.Date.Day == 18)
            e.Cell.Controls.Add(new LiteralControl("<br />Holiday"));

      }

   </script>

</head>

<body>

   <form id="form1" runat="server">

      <h3>DayRender Event Example</h3>

      <asp:Calendar id="calendar1" 
                    OnDayRender="DayRender"
                    runat="server">

         <WeekendDayStyle BackColor="gray">
         </WeekendDayStyle>

      </asp:Calendar>

   </form>

</body>
</html>
   

Open in new window

0
 

Author Comment

by:InorbitalWeb
ID: 34960435
Thanks for the reply but this is not what i want to accomplish in my calendar. I don't want to highlight any cells of calendar. Check at the url http://www2.heritagetrust.on.ca/EWG/Events.aspx when hover over the event on date 16 that event is from feb to april and i want it to render the same event, same style that is title of the event till April.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34960629
In the DayRender event, you can do anything you want to the cell, since you have a reference in e.Cell.  I don't believe that the calendar supports what you want any other way (I could be wrong, though, so don't quote me on that)...
0
 

Author Comment

by:InorbitalWeb
ID: 34962478
Even in this day render event i am not quite sure how i am going to get the list of dates between starting date and ending date of an event to render the same event for those all the dates??
And populate the cells matching to those list of dates with the same event

Any ideas for this situation??

Thanks!!
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 34963122
If you look at how the calendar is rendered (pictured below in IE 8 Developer Tools), each cell is a <td> element.  

The DayRender event handler is defined with DayRenderEventArgs.  That class has the Day and Cell properties.  With the Day property, you can check the date for the cell, and with the Cell property, you can modify the cell contents, such as adding a <div> element with anchors, breaks, headers, etc.

DayRenderEventArgs
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.dayrendereventargs.aspx
Screenshot.png
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question