Solved

Displaying Multi date events in calendar control

Posted on 2011-02-22
5
847 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 500 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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 …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 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