Click here to Skip to main content
Click here to Skip to main content

WSS Event Calendar Listing Web Part

By , 25 May 2009
 
Screenshot - preview1.gif Screenshot - preview2.gif

Introduction

For use in Microsoft Windows SharePoint Services (WSS) 3.0, this Event Calendar Listing Web Part displays events (or any calendar list) in a compact widget style calendar.

Background

I was inspired by Kapoorisha's article Calendar Web Part for Sharepoint that Displays & Gives Details of Events from an Event List in building this Web Part. It is based on the same idea that SharePoint calendar events are shown in a custom calendar Web control that inherits from the standard ASP.NET Calendar Web control. My design goal is to make the Web Part more flexible, efficient and visually appealing.

Description

The EventCalendarListWebPart Web Part calls two custom Web controls, EventCalendar and EventListing, to render events. Each of these two Web controls can be used independently of the Web part which functions more as a wrapper.

EventCalendar is a custom Web control that inherits from System.Web.UI.WebControls.Calendar. Days with events are rendered in Selected style with rollover pop-up showing a list of events on that particular day. The pop-up uses dynamic HTML instead of Ajax and is based on Dynamic Drive's Rich HTML Balloon Tooltip. When user mouse hovers an event title, a tooltip showing the event start and end time is shown.

In EventCalendar, events are fetched from a calendar list using a SPQuery as follows:

<Where>
    <DateRangesOverlap>
        <FieldRef Name="EventDate" />
        <FieldRef Name="EndDate" />
        <FieldRef Name="RecurrenceID" />
        <Value Type="DateTime"><Month /></Value>
    </DateRangesOverlap>
</Where> 

The above query retrieves all events that occur on days shown in the current calendar view, not just the current or selected month. So it may include the last few days of the previous month and/or the first few days of the next month. In the overridden event OnDayRender, the control will check if any of the retrieved events fall on the day and render the necessary child controls appropriately.

EventListing is a custom Web control that shows upcoming events in a list format. It fetches events from a calendar list using a SPQuery as follows:

<Where>
    <DateRangesOverlap>
        <FieldRef Name="EventDate" />
        <FieldRef Name="EndDate" />
        <FieldRef Name="RecurrenceID" />
        <Value Type="DateTime"><Now /></Value>
    </DateRangesOverlap>
</Where>
<OrderBy>
    <FieldRef Name="EventDate" />
</OrderBy> 

EventCalendarListWebPart functions as a wrapper for EventCalendar and EventListing. It has the following public properties:

  • SiteUrl - (Site URL) Server relative URL of the site. If left blank, current site is used.
  • ListName - (List Name) Name of a calendar list in the current site. Default is Events.
  • ShowCalendar - (Show Calendar?) Default is true.
  • ShowListing - (Show Listing?) Default is true.
  • FirstDayOfWeek - (First day of week) Default is Default, i.e. as specified in system setting.
  • NumDaysInEventListing - (Number of days to show in event listing) Default is 3. Please note days with no events do not count.
  • SiteRelativeEventItemUrl - (Site Relative URL for Event Detail Page) In some situations like in a publishing site where you have calendar lists, you may want to direct users to a custom event detail page with a consistent look and feel to the rest of the publishing site. If provided, when a user clicks on the event title, the user will be redirected to this custom page with the event item ID automatically appended to the URL as a querystring.
  • CssClassEventListing - (CSS class name for event listing)
  • CssClassCalendar - (CSS class name for calendar control) This is the CSS class for the outermost calendar table. If provided, you must also specify CssClassTitle because of quirks in System.Web.UI.WebControls.Calendar.
  • CssClassTitle - (CSS class name for the title heading) This is the CSS class for the part where it says July, 2008 in the title.
  • TitleBackColor - (Background color for title heading) Though you can specify the title background color in CssClassTitle, you should do it in this property instead because of quirks in System.Web.UI.WebControls.Calendar, again.
  • CssClassHeader - (CSS class name for the section that displays the day of the week)
  • CssClassNextPrev - (CSS class name for the next and previous month navigation elements)
  • CssClassDay - (CSS class name for the days in the displayed month)
  • CssClassEvent - (CSS class name for the days with event(s))
  • CssClassToday - (CSS class name for today's date)
  • CssClassWeekend - (CSS class name for the weekend dates)
  • CssClassOtherMonth - (CSS class name for the days that are not in the displayed month)
  • OnMouseOverBackgroundColor - (Background color (e.g. "#FFE1BB") when mouse over a day)

The rollover pop-up functionality in EventCalendar requires supporting files balloontip.js and balloontip.css. balloontip.js has been customized from Dynamic Drive's version to delay hiding the pop-up when mouse is over the pop-up. It is treated as Embedded Resources in Visual Studio. In code, reference the JavaScript file using Page.ClientScript.GetWebResourceUrl. You will need to pass in the file in the form of [Assembly of project].[Folder containing resource].[Filename of resource]. In AssemblyInfo.cs, include ballontip.js in the same format like:

[assembly: System.Web.UI.WebResource
    ("QuestechSystems.SharePoint.ClientScripts.balloontip.js", "text/javascript")]

The Web Part also uses a resource file to store all messages and property attribute UI strings. It demonstrates how to develop a custom class that inherits WebDescriptionAttribute, WebDisplayNameAttribute or CategoryAttribute and returns a localized string from your own Resource Manager.

The sample Visual Studio 2008 solution includes all the support files you need to build and deploy this Web Part, minus strong name key files (*.snk). It contains three projects: Deployment, Features and SharePoint. The SharePoint project contains source codes for the Web Part and the two web controls. The Features project contains all the features to support the SharePoint project. The Deployment project contains a pre-build script to aggregate all the files needed for deployment. It contains a Solution directory where a WSP file is generated and deployed by a post-build script.

This structure of Visual Studio solution and projects is scalable to full blown MOSS/WSS development and deployment. You could add additional projects like SharePoint.Publishing for MOSS publishing development or SharePoint.ApplicationPages for customization of administrative layout pages. Within your projects, you could have other custom components like user controls, custom fields, feature receivers, etc.

Installation

Using stsadm, install solution file QuestechEventCalendarList.wsp in \Deployments\Solution\:

stsadm -o addsolution -filename QuestechEventCalendarList.wsp

Go to SharePoint Central Administration/Operations/Global Configuration-Solution Management. Deploy the installed solution to selected Web applications. In the site collection where the solution is deployed, activate the Site Collection Feature Questech Systems Event Calendar Listing Web Part. After that, the Event Calendar Listing Web Part (listed under Questech Systems) should be available for you to add to pages.

As mentioned, the rollover pop-up functionality depends on balloontip.css (in \SharePoint\Styles). If you have a custom CSS file for your site already, you could just copy the content out from balloontip.css and paste it into your custom CSS. If you do not have a custom CSS file, you would need to either add it through the SharePoint UI Site Settings interface or insert it in your custom master page or page layout (for MOSS). At the minimum, you would need the first CSS class definition balloonstyle in balloontip.css.

To achieve the same look and feel as shown in the preview screenshots shown at the top, I specify the following values in the Web part properties:

  • CssClassEventListing - EList
  • CssClassCalendar - ECal
  • CssClassTitle - ECalTitle
  • TitleBackColor - #BBD367
  • CssClassToday - ECalToday
  • OnMouseOverBackgroundColor - #E6935E

Please note that though this Web Part is licensed under The Code Project Open License, the Rich HTML Balloon Tooltip is licensed separately under its own Terms of Use.

References

  1. CodeGuru: Write Custom WebParts for SharePoint 2007
  2. Eric Stallworth: How To Build a Solution Pack (WSP)
  3. The Code Project: Calendar Web Part for Sharepoint that Displays & Gives Details of Events from an Event List
  4. Dynamic Drive: Rich HTML Balloon Tooltip

History

  • V1.4 - 2009.05.22
    • Converted Visual Studio solution projects to version 2008
    • Added SiteUrl property
    • New SharePoint Solution QuestechEventCalendarList.wsp and assembly QuestechSystems.SharePoint.EventCalendarList.dll. This allows my other sample solutions in CodeProject to co-exist with this Web Part.
    • Renamed feature from QuestechWebParts to QuestechEventCalendarListWebPart
  • V1.3 - 2009.01.04
    • Added FirstDayOfWeek property
    • Fixed error when calendar contains items sent by e-mail
  • V1.2 - 2008.09.20
    • Fixed incorrect pop-up events when more than one Web part is added to a page and each is associated with a different calendar list
  • V1.1 - 2008.07.16
    • Fixed incorrect event item URL when Web part is added to a sub site.
  • V1.0 - 2008.07.12 - Base

License

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

About the Author

Stephen Huen
Web Developer Questech Systems
Canada Canada
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionElist not displayingmemberRpulcino22 Aug '12 - 8:48 
Hello-
Totally hack-novice and have the Questech Calendar web part working well on many site collections. However, there is one site that I noticed the list of events is not showing up below the calendar display.
 
I have verified that the configuration is the same as it is for sites that the listing is working and that the box is checked for "show list"
 
Any ideas? Thanks much!
Roarke
QuestionHow to display location?memberelee53211 Nov '11 - 16:24 
How can I have the location field displayed?
QuestionDisplay in dialogmemberelee5328 Oct '11 - 16:48 
When clicking on the link for an event, how can I get the details to come up in a dialog rather than a webpage (i.e. DispForm.aspx).
 
Thanks and great webpart by the way!
Questionwss 2.0 compatabitymembertmarina2 Aug '11 - 0:49 
hi,
I know it's a little bit outdated, but will this WP work for WSS2.0?
Questioncategory wise css display of baloon tip...memberp yadav10 Jul '11 - 16:35 
My calendar List has custom categories like Public holiday - RDO etc. etc...
Can I have different baloontip style for each category event displayed in the calendar.
Pyadav...

GeneralBalloontip.cssmemberChristopher H. Schulz11 May '11 - 6:44 
Hello everyone..
 
I openly confess to being a rank amateur at the world of Sharepoint.
 

Right now, if I try and add the calendar web part I get an error stating: "The Web Part or Web Form control on this page cannot be displayed or imported. The type is not registered as safe."
 
I was able to get through the stsadm stage and deployed the web part just fine. In fact, the Questech Calendar shows up on my list of available web parts to choose from when I click 'Add Web Part'.
 
I think my issue is somehow related to the balloontip.css code which I have yet to add.
 
Is there a way to add the code without using Sharepoint designer?
 

I was hoping I could just slide it into Core.css and it would take, but that has not been the case.
 
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\STYLES\Core.css
 
I'm using WSS 3.0.
 
What am I doing wrong? Any ideas?
 
-Chris
GeneralRe: Balloontip.cssmemberStephen Huen19 May '11 - 7:59 
The error probably means you are using the web part in a web application that the solution is not deployed to. Please make sure in SharePoint Central Administration/Operations/Global Configuration-Solution Management, you are deploying the solution to all the web applications that you are using the web parts.
GeneralRe: Balloontip.cssmemberChristopher H. Schulz19 May '11 - 10:01 
Thank you for your help!
Generalupdate resourcememberDespa2210 Dec '10 - 22:08 
Thanks for a great wp.
 
1)
is there a way I can update the resource file the web part reads from ??
 
i want to change the language to frensh or arabic.
 
2)
I opened the solution using vs2008, i changed some layout of the wp.
 
unfortunatlly, when i build the solution i didn't see the changes on the site.
 

 

Thank You ...
GeneralMy vote of 5memberAndrewSmith15 Nov '10 - 3:26 
Well Done Job!
GeneralWSS Event Calendar Listing Web Part shows up as jsuta title but no mini calender with eventsmemberhitu210018 Aug '10 - 7:20 
downloaded the zip file, ran the deployment script, now i was able to see the webpart when i try to add webparts but its just shows up as the title not mini calander with events, please advice

GeneralRe: WSS Event Calendar Listing Web Part shows up as jsuta title but no mini calender with eventsmemberStephen Huen18 Aug '10 - 7:41 
Please make sure the siteurl and listname are specified properly and the css is included per deployment instruction.
QuestionCan you get a filtered view on the calendar?memberBoise - Jackson12 Aug '10 - 11:19 
Is there any way to get a filtered view of the list items to display on the calendar? There are some list items that I don't want to be displayed for all users.
 
Thanks.
 
-tom
QuestionCan't get calendar to show as widgetmemberBoise - Jackson11 Aug '10 - 4:33 
I've installed the solution file according to the directions, and then I added the Event Calendar webpart to an existing aspx page I had. Initially the calendar shows as a widget, but as soon as I start adding events to the list, the calendar starts "blowing up" on me -- for each day containing an event, the calendar writes out the full date beneath the day number (eg "Thursday, August 26, 2010") and it shows the description of the event, instead of simply allowing me to hover over the day in order to get a popup of the event details.
 
I figured at this point that the problem was probably due to not yet having added the balloon files, so I uploaded the balloon.js and balloon.css files to document libraries on my top-level website, and then I created stylesheet links to these two files in the HEAD of my master page. Still having the same problem!
 
What am I doing wrong??
 
-tom
AnswerRe: Can't get calendar to show as widgetmemberStephen Huen11 Aug '10 - 21:21 
Hi Tom,
 
The js file is already included in the web part so you don't need to do anything with the javascript file. You just need to include balloontip.css. Please do a browser view source on the web page to see balloontip.css is properly included, or you can include it via alternate css through the browser UI. Don't forget to check in and approve balloontip.css you uploaded to the document library (and users have read access to it).
 
Stephen
GeneralRe: Can't get calendar to show as widgetmemberBoise - Jackson12 Aug '10 - 3:51 
Hey Stephen.
 
Thanks for the info about not needing the js file.
 
After I posted my message, I went ahead and put a copy of the .css file in the 12 hive, under a new folder TEMPLATE\LAYOUTS\JCUSTOM\Styles.
 
I linked to it from my masterpage with the following line:
 
<SharePoint:CSSRegistration Name="/JCustom/Styles/balloontip.css" runat="server"/>
 
It "seemed" to load ok with this path and filename (when I tried other paths I got error messages on the webpage about not being able to find the file, but for this path the webpage loaded with no errors).
 
I just did a "view source" of the webpage in the browser like you suggested, and found this entry:
 
<link rel="stylesheet" type="text/css" href="/JCustom/Styles/balloontip.css"/>
 
The calendar is still not behaving properly however Frown | :-( .
GeneralRe: Can't get calendar to show as widgetmemberStephen Huen12 Aug '10 - 7:25 
The path /JCustom/Styles/balloontip.css does not seem right. If the source says
 
<link rel="stylesheet" type="text/css" href="/JCustom/Styles/balloontip.css"/>
 
test the link above by typing the url in the browser to see if you are able to access it, e.g. http://<server>/JCustom/Styles/balloontip.css. It probably should be something like /_layouts/JCustom/Styles/balloontip.css in your case.
GeneralRe: Can't get calendar to show as widgetmemberBoise - Jackson12 Aug '10 - 10:38 
Wow! You hit the nail on the head. No error message, but still the path was not correct.
 
I added "/_layouts" to the front of the path, and like magic the calendar webpart started working.
 
Thanks for helping me get this working. I think this calendar webpart is exactly what we have been looking for!
 
-tom
GeneralDLL Licensemembermuthe.ashok30 Jul '10 - 0:10 
Hi,
 
The "dll"s which are using in this project are Licensed version or freeware.
Please let me know.
 
I would like to use this dlls to build my solution. Intern I'll give that solution to my client.
 

Thanks
Ashok. M
GeneralTime QuestionmemberMember 247097014 Jul '10 - 11:29 
How would you make it so the time displays on it's on line and so it only shows StartTime and not Endtime? I love the web part!
 
Thanks!
GeneralMy vote of 5memberssaurabhdhingra27 Jun '10 - 19:46 
This is an article with a great web part for SharePoint
QuestionSharePoint 2010memberTimohthy J. Carlson25 Jun '10 - 8:19 
I've got this calendar working on my SP2010 homepage (I realize it is for WSS). It does not, however, display on other sites although the webpart shows as an option to use on the other sites.
 
a. will you have a vs for SP2010 soon?
b. is there anything I can do with the vs to get it to display on other pages?
c. the calendar is not displaying as centered in my webpart zone. Is there anything I can to fix this?
 
Thanks!
AnswerRe: SharePoint 2010memberStephen Huen25 Jun '10 - 16:49 
a) Please check out Event Calendar Listing Web Part (SharePoint 2010)

b) "get it to display on other pages". I am not quite sure what you mean. The calendar list can be from other sites in the same site collection by specifying SiteUrl.

c) I would use css.
GeneralRe: SharePoint 2010memberTimohthy J. Carlson29 Jun '10 - 15:25 
Thank you very much for your reply. I was mistaken.
 
a)I am using the Event Calendar Web Part for SharePoint 2010 on my site.
b)What I mean by displaying on other pages is that I've got it working on my top-level site just fine. On any of my subsites, it is a web part that's available to add but it does not display when I add it and attempt to configure it regardless of the URL that I use in the Site Url field or the Site Relative Event Url. For example, on one site where I have used an OOTB SP calendar, I reference this calendar in the Site Url but I get this message: There is no Web named "/http://spheredev.dixon-hughes.com/Resources/FirmTechnologyGroup/Lists/FTG%20Calendar/calendar.aspx". Even using a relative URL does not help.
 
c) I've attempted to use CSS but to no avail. thanks!
GeneralRe: SharePoint 2010memberStephen Huen30 Jun '10 - 7:09 
"/http://spheredev.dixon-hughes.com/Resources/FirmTechnologyGroup/Lists/FTG%20Calendar/calendar.aspx"
 
Site Url is Server relative url of the SITE, not calendar. Try something like "/Resources/FirmTechnologyGroup"

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 25 May 2009
Article Copyright 2008 by Stephen Huen
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid