Click here to Skip to main content
15,173,985 members
Articles / Productivity Apps and Services / Sharepoint / SharePoint 2010
Posted 2 May 2010


40 bookmarked

Event Calendar Listing Web Part (SharePoint 2010)

Rate me:
Please Sign up or sign in to vote.
4.80/5 (18 votes)
4 Jul 2014CPOL6 min read
Displays SharePoint events (or any calendar list) in a compact widget style calendar


[A SharePoint 2013 version is available here.]

For use in Microsoft SharePoint 2010, this Event Calendar Listing Web Part displays events (or any calendar list) in a compact widget style calendar. It supports views and offers ajax support with rollover tooltip behaviour.


I was inspired by CodeProject 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.


The EventCalendarListWebPart Web Part calls two custom Web controls, EventCalendar and EventListing, to render events.

EventCalendar is a custom Web control that inherits from System.Web.UI.WebControls.Calendar. Days with events are rendered in Selected style with rollover tooltip showing a list of events on that particular day. The tooltip uses Dynamic Web Coding's JavaScript Tooltips. 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:

<span id="ArticleContent"><Where>
        <FieldRef Name="EventDate" />
        <FieldRef Name="EndDate" />
        <FieldRef Name="RecurrenceID" />
        <Value Type="DateTime"><Month /></Value>
</Where> </span>

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. When a custom calendar view is specified, the view's query will be used instead. This custom view should be based on the Calendar view type. 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:

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

Again when a custom listing view is specified, the view's query will be used instead. This custom view should be created based on the OOTB "Current Events" view.

EventCalendarListWebPart functions as a wrapper for EventCalendar and EventListing. It also wraps an <a href="">UpdatePanel</a> around EventCalendar so clicking previous or next month does not cause the entire page to refresh. The web part has the following public properties:

  • SiteUrl - (Site URL) Server relative URL of the site. If left blank, current site is used.
  • ListTitle - (List Title) Name of a calendar list. Default is Calendar.
  • 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.
  • EnableAsyncUpdate - (Enable Asynchronous Update) Enabling this option will make month navigation work without full page refreshes. Experimental, may not work in all pages or browsers. Default is false.
  • ShowCalendar - (Show Calendar?) Default is true.
  • CalendarViewTitle - (Calendar View Name) Name of view based on Calendar view type.
  • FirstDayOfWeek - (First day of week) Default is Default, i.e. as specified in system setting.
  • CssClassCalendar - (CSS class name for calendar control) This is the CSS class for the outermost calendar table.
  • CssClassTitle - (CSS class name for the title heading) This is the CSS class for the part where it says March, 2014 in the title.
  • 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)
  • ShowListing - (Show Listing?) Default is true.
  • ListingViewTitle - (Listing View Name) Name of view based on Current Events view.
  • NumDaysInEventListing - (Number of days to show in event listing) Default is 3. Please note days with no events do not count.
  • CssClassEventListing - (CSS class name for event listing)

All JavaScript files are referenced through the use of ScriptLink while all CSS files are referenced through the use of CssRegistration.

The web part comes with following default property values which reflect the same look and feel as shown in the preview screenshot shown at the top:

  • CssClassCalendar - ecl-calendar
  • CssClassDay - ecl-day
  • CssClassEvent - ecl-event
  • CssClassToday - ecl-today
  • CssClassWeekend - ecl-weekend
  • CssClassOtherMonth - ecl-other-month
  • CssClassEventListing - ecl-listing

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

The sample Visual Studio 2013 Update 1 solution includes all the support files you need to build and deploy this Web Part, minus the strong name key file. It makes full use of the built-in SharePoint integration. No more third party tools or custom pre and post build scripts are needed to build the SharePoint solution file.


If you are upgrading from a previous version, please refer to Version History for any special upgrade instructions.

Open SharePoint 2010 Management Shell, add solution file QuestechSystems.SharePoint.EventCalendarList.wsp using Add-SPSolution like


Go to SharePoint 2010 Central Administration/System Settings/Manage farm solutions. 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.

Tips: To control the width of the calendar, specify a fixed width to the web part in the web part properties under Appearance.

Please note that though this Web Part is licensed under The Code Project Open License, JavaScript Tooltips is licensed separately under its own Terms of Use.


  • V2.0 - 2014.07.04
    • Upgrade instructions from V1.1
      1. Delete all instances of old web parts.
      2. Retract old solution using PowerShell or via SharePoint 2010 Central Administration.
      3. Follow installation instructions as described in Installation section.
    • Supports views.
    • Experimental Ajax support so clicking previous or next month will not refresh the entire page. Turn on Enable Asynchronous Update to enable this feature. May not work in all pages/browsers.
    • Built-in CSS on styling and rollover tooltip behaviour so no more dependence on external CSS.
    • Switched to Dynamic Web Coding's JavaScript Tooltips for better tooltip placement.
  • V1.1 - 2010.06.29
    • Made Event Calendar Ajax compatible. (If the calendar web part or web control is wrapped in an UpdatePanel, tooltips will continue to work post asynchronous postback. Thanks jules_anime for code tip.)
  • V1.0 - 2010.05.02 - Base


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


About the Author

Stephen Huen
Software Developer (Senior)
Canada Canada
A Microsoft Certified Professional Developer and Technology Specialist.

Experience and expertise in SharePoint 2016 / 2013 / 2010 / 2007.

Role ranges from a developer in a multi-person team to a solution consultant with expert-level skills, leading a project to completion status.

Proven experience working effectively in a team environment and a self-managed environment.

Comments and Discussions

QuestionCSS Configuration and Cross Platform support Pin
Member 325923919-Aug-15 0:13
MemberMember 325923919-Aug-15 0:13 
GeneralMy vote of 4 Pin
Santhakumar Munuswamy @ Chennai23-May-15 9:17
professionalSanthakumar Munuswamy @ Chennai23-May-15 9:17 
QuestionAssociate with calendar list Pin
Member 1165250729-Apr-15 10:27
MemberMember 1165250729-Apr-15 10:27 
QuestionChanging the color or the web part? Pin
Member 1152018812-Mar-15 8:25
MemberMember 1152018812-Mar-15 8:25 
QuestionCSS for HTML5 on SharePoint 2010? Pin
treesprite3-Mar-15 9:12
professionaltreesprite3-Mar-15 9:12 
QuestionEvent Listing for Current Month only Pin
Member 1115091911-Dec-14 2:41
MemberMember 1115091911-Dec-14 2:41 
Question[My vote of 1] Reference a calendar in a sub-site? Pin
Jim Blanchard1-Oct-14 5:29
MemberJim Blanchard1-Oct-14 5:29 
GeneralMy vote of 5 Pin
MdSudirman21-Sep-14 23:35
MemberMdSudirman21-Sep-14 23:35 
QuestionEvent List not being displayed Pin
Member 333111322-Jul-14 23:34
MemberMember 333111322-Jul-14 23:34 
QuestionVery good article! Pin
Volynsky Alex5-Jul-14 5:57
professionalVolynsky Alex5-Jul-14 5:57 
Bugevents more than 2 month transitions away do not show Pin
Member 109217773-Jul-14 1:14
MemberMember 109217773-Jul-14 1:14 
GeneralRe: events more than 2 month transitions away do not show Pin
Stephen Huen3-Jul-14 17:13
MemberStephen Huen3-Jul-14 17:13 
QuestionUpdated code Required Pin
Maheshbabuk27-May-14 5:22
MemberMaheshbabuk27-May-14 5:22 
AnswerRe: Updated code Required Pin
Stephen Huen28-May-14 11:21
MemberStephen Huen28-May-14 11:21 
QuestionThis is a great article! Pin
Volynsky Alex30-Mar-14 6:28
professionalVolynsky Alex30-Mar-14 6:28 
QuestionTrying to remove the time from list Pin
Member 1059197012-Feb-14 9:45
MemberMember 1059197012-Feb-14 9:45 
QuestionPop up is not working Pin
Meenakumari Natarajan4-Oct-13 4:29
MemberMeenakumari Natarajan4-Oct-13 4:29 
QuestionSubscribe the event Pin
onixs28-May-13 17:49
Memberonixs28-May-13 17:49 
QuestionSite Url Pin
SPMarmedsa9-Apr-13 1:05
MemberSPMarmedsa9-Apr-13 1:05 
QuestionError when adding web part to page Pin
Member 850438929-Mar-13 4:11
MemberMember 850438929-Mar-13 4:11 
QuestionPopup doesn't work Pin
JuniorPointer4-Feb-13 1:23
MemberJuniorPointer4-Feb-13 1:23 
GeneralMy vote of 5 Pin
Ksenia2617-Dec-12 23:47
MemberKsenia2617-Dec-12 23:47 
QuestionUbication Pin
marti_m9-Dec-12 23:33
Membermarti_m9-Dec-12 23:33 
QuestionRe: Ubication Pin
Member 976137516-Jan-13 6:13
MemberMember 976137516-Jan-13 6:13 
QuestionMultiple day events shows up multiple times in events list Pin
Member 93751628-Nov-12 8:12
MemberMember 93751628-Nov-12 8:12 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.