Click here to Skip to main content
12,241,270 members (59,210 online)
Click here to Skip to main content
Add your own
alternative version


368 bookmarked

DayPilot - Building an Outlook-Like Calendar Component for ASP.NET

, 15 Mar 2015 Apache
Rate this:
Please Sign up or sign in to vote.
A good-looking ASP.NET control that shows events visually arranged in a day calendar. Includes design-time support and data binding.

Version 5.0

March 16, 2015: DayPilot Lite for ASP.NET WebForms 5.0 [] now supports calendar drag and drop:

  • event moving
  • event resizing
  • time range selecting

Source and binary available for download [].


See also the follow-up articles:

These articles introduce a new DayPilot version for ASP.NET MVC which supports drag & drop AJAX operations (event moving, resizing, and creating).

HTML5/JavaScript Version

DayPilot Lite is also available for HTML5/JavaScript:

The latest release includes AngularJS event calendar [] plugin.

Building an Outlook-Like Calendar Component for ASP.NET

The story is simple and you might have already heard it: I needed a component and because I wasn't able to find a good one I decided to write it. I was thinking like this: It would take me two hours to find it, another two hours to understand it and another two hours to customize it. Six hours. In six hours, I should be able to write a simple component by myself.


  • Reusable ASP.NET component for showing the events in day/week/work week views.
  • HTML5 support
  • Full CSS-based styling.
  • Supports all modern browsers (Chrome, Firefox, Internet Explorer, Safari, Opera, mobile browsers).
  • Visual Studio 2010/2012/2013 (also works with 2005 and 2008)
  • Azure support
  • Internationalization support (automatic date and time formatting, 12/24 clock support).
  • Accepts data in many forms, including a DataTable, List, and other collections of custom objects.
  • Support for database backends (Microsoft SQL Server, MySQL, etc.)
  • Simple mapping of data object fields (DataStartField, DataEndField, DataIdField, DataTextField).
  • User-defined JavaScript/server-side action for clicking the event.
  • User-defined JavaScript/server-side action for clicking the free time.
  • Support for business hours - doesn't show the time outside the working hours unless there is an event.
  • Support for events started before or finish after the current day.
  • Support for overlapping events (two or more events for a particular moment).
  • Commercial-friendly open-source license (Apache Software License 2.0)

Algorithm for Arranging Concurrent Events

The following mechanism is used to arrange the events:

  • "Event" class will keep the basic information about the event, like starting and ending time, title, etc.
  • "Day" class will keep all the events for a certain day. It will be able to load the events from a DataTable. Each day can contain zero or more Blocks.
  • "Block" class will contain events that overlap with one another. Each Block contains one or more Columns.
  • "Column" class will contain all the events inside a Block that can be in a single Column.

Let's demonstrate it visually:

The algorithm can be described in the following steps:

  1. Shorten all the Events so that they don't overlap to another day (e.g. if something starts yesterday, let's make it start today at 00:00).
  2. Extend the Events' duration to 30 minutes blocks (we would have problems showing a duration of 5 minutes, 5 seconds - it wouldn't be possible to write any text into a rectangle of such a small height).
  3. Find Blocks:
    • Order all the events by the starting time (primary) and by the ending time in reverse (secondary) - longer events go closer to the left.
    • Iterate through the events - if it overlaps with the previous add it to the current Block; otherwise create a new Block.
  4. Arrange Events into Columns inside a Block (do this for each Block):
    • Find a moment with the most overlaps and count the overlaps. Create that many numbers of Columns.
    • Arrange Events into Columns - find the first free Column from the left and place it there.

Now, we can calculate the position of each Event because we know the Blocks and Columns:

  • Left: (the column number)/(total count of columns for the owner block) in percent.
  • Width: 1/(total count of columns) in percent
  • Top: (starting time)*(hour height)
  • Height: (duration)*(hour height)

Quick-Start Example

ASP.NET Control Declaration (.aspx)

<DayPilot:DayPilotCalendar ID="DayPilotCalendar1" runat="server" 

Loading data (.aspx.cs)

protected void Page_Load(object sender, EventArgs e)
  if (!IsPostBack)
      DayPilotCalendar1.StartDate = firstDayOfWeek(DateTime.Now, DayOfWeek.Sunday);
      DayPilotCalendar1.DataSource = getData();

More information about event loading [].

See also the DayPilot Tutorial for a step-by-step setup guide.

Scheduler (3.0)

DayPilot Lite 3.0 supports Scheduler ASP.NET control that allows you to display a scheduler for multiple resources side-by-side.

See also:

Gantt Chart (3.2)

DayPilot Lite 3.2 supports Gantt Chart ASP.NET control (displaying one task per line).

See also:

CSS Theme Styling (4.0)

DayPilot Lite 4.0 supports full calendar and scheduler CSS styling.

You can design your own CSS theme in the online theme designer:

Built-In CSS Theme (4.1)

DayPilot Lite 4.1 includes a built-in CSS theme. The CssOnly mode (full calendar CSS styling mode) is now enabled by default. The calendar default CSS theme can be displayed without any external dependencies.

NuGet Package

DayPilot Lite is also available as a NuGet package:



This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


About the Author

Dan Letecky
Czech Republic Czech Republic
My open-source event calendar/scheduling AJAX controls:

DayPilot for JavaScript/HTML5/jQuery
DayPilot for ASP.NET
DayPilot for MVC
DayPilot for Java

You may also be interested in...

Comments and Discussions

Questionfree? Pin
KhinLLK25-Apr-07 0:47
memberKhinLLK25-Apr-07 0:47 
AnswerRe: free? Pin
Dan Letecky25-Apr-07 3:08
memberDan Letecky25-Apr-07 3:08 
GeneralLicense question Pin
PhilBaker31-Jan-07 4:43
memberPhilBaker31-Jan-07 4:43 
GeneralRe: License question Pin
Dan Letecky31-Jan-07 22:46
memberDan Letecky31-Jan-07 22:46 
GeneralEvent FreeTimeClick Pin
Roseville5-Jan-07 14:32
memberRoseville5-Jan-07 14:32 
QuestionIs it possible to call Java Script Funtion Pin
Roseville5-Jan-07 12:42
memberRoseville5-Jan-07 12:42 
Generaloverlapswith Pin
TommieKokkie18-Dec-06 11:44
memberTommieKokkie18-Dec-06 11:44 
GeneralRe: overlapswith Pin
Dan Letecky18-Dec-06 12:56
memberDan Letecky18-Dec-06 12:56 
QuestionloadEventsToDay Pin
TommieKokkie8-Dec-06 2:34
memberTommieKokkie8-Dec-06 2:34 
AnswerRe: loadEventsToDay Pin
Dan Letecky10-Dec-06 22:58
memberDan Letecky10-Dec-06 22:58 
QuestionRefreshing DayPilot Control Pin
EnriqueSu17-Oct-06 6:21
memberEnriqueSu17-Oct-06 6:21 
QuestionData binding &amp; integration with webcontrols.calendar [modified] Pin
EnriqueSu15-Sep-06 14:46
memberEnriqueSu15-Sep-06 14:46 
AnswerRe: Data binding &amp; integration with webcontrols.calendar Pin
Dan Letecky2-Oct-06 21:58
memberDan Letecky2-Oct-06 21:58 
QuestionHow about and "Enabled" style/property? Pin
Spotnick13-Sep-06 4:47
memberSpotnick13-Sep-06 4:47 
GeneralDayPilot 2.0.1 released Pin
Dan Letecky23-Jun-06 4:00
memberDan Letecky23-Jun-06 4:00 
Questionediting Pin
eighteenpinkpandas12-Jun-06 4:18
membereighteenpinkpandas12-Jun-06 4:18 
Generalappearance Pin
r.waymen11-Jun-06 22:56
memberr.waymen11-Jun-06 22:56 
GeneralRe: appearance Pin
Dan Letecky11-Jun-06 23:07
memberDan Letecky11-Jun-06 23:07 
QuestionRe: appearance Pin
r.waymen12-Jun-06 0:25
memberr.waymen12-Jun-06 0:25 
AnswerRe: appearance Pin
Dan Letecky12-Jun-06 1:48
memberDan Letecky12-Jun-06 1:48 
AnswerRe: appearance Pin
Dan Letecky12-Jun-06 7:08
memberDan Letecky12-Jun-06 7:08 
GeneralDayPilot 2.0 released Pin
Dan Letecky9-Jun-06 13:55
memberDan Letecky9-Jun-06 13:55 
GeneralEvents Renderer function in a wrong way Pin
Keynan_d24-May-06 19:39
memberKeynan_d24-May-06 19:39 
GeneralRe: Events Renderer function in a wrong way Pin
Dan Letecky9-Jun-06 13:53
memberDan Letecky9-Jun-06 13:53 
GeneralDayPilot 2.0 Beta 1 released Pin
Dan Letecky14-May-06 5:11
memberDan Letecky14-May-06 5:11 
QuestionParsing error Pin
Willem_Le_Roux4-May-06 23:54
memberWillem_Le_Roux4-May-06 23:54 
AnswerRe: Parsing error Pin
Dan Letecky14-May-06 5:08
memberDan Letecky14-May-06 5:08 
GeneralConcurrent events Pin
hillBillyDLX23-Mar-06 1:11
memberhillBillyDLX23-Mar-06 1:11 
GeneralRe: Concurrent events Pin
Dan Letecky12-Apr-06 7:09
memberDan Letecky12-Apr-06 7:09 
GeneralRe: Concurrent events Pin
Dan Letecky14-May-06 5:04
memberDan Letecky14-May-06 5:04 
GeneralIny Meny Miny mo Pin
The_Myth21-Mar-06 23:41
memberThe_Myth21-Mar-06 23:41 
GeneralRe: Iny Meny Miny mo Pin
Dan Letecky14-May-06 5:05
memberDan Letecky14-May-06 5:05 
GeneralDynamic loading...postback Pin
atilston21-Mar-06 4:28
memberatilston21-Mar-06 4:28 
GeneralRe: Dynamic loading...postback Pin
Dan Letecky14-May-06 5:06
memberDan Letecky14-May-06 5:06 
Questionproblem showing up event Pin
kohyeehuei4-Mar-06 6:41
memberkohyeehuei4-Mar-06 6:41 
AnswerRe: problem showing up event Pin
Dan Letecky14-May-06 5:07
memberDan Letecky14-May-06 5:07 
QuestionRe: problem showing up event Pin
obinna_eke8-Oct-06 23:24
memberobinna_eke8-Oct-06 23:24 
GeneralDayPilot 1.1 Released Pin
Dan Letecky3-Feb-06 13:27
memberDan Letecky3-Feb-06 13:27 
GeneralProblem with databind Pin
kevinof2-Feb-06 11:48
memberkevinof2-Feb-06 11:48 
GeneralRe: Problem with databind Pin
Dan Letecky3-Feb-06 13:24
memberDan Letecky3-Feb-06 13:24 
GeneralRe: Problem with databind Pin
ali zarei sani24-Mar-06 11:00
memberali zarei sani24-Mar-06 11:00 
QuestionWhen is the new version going to be released? Pin
dimkasta1-Feb-06 23:47
memberdimkasta1-Feb-06 23:47 
AnswerRe: When is the new version going to be released? Pin
Dan Letecky1-Feb-06 23:50
memberDan Letecky1-Feb-06 23:50 
QuestionWindows version? Pin
Rom200015-Jan-06 16:10
memberRom200015-Jan-06 16:10 
GeneralPostback Pin
Matthew Hazlett2-Jan-06 18:10
memberMatthew Hazlett2-Jan-06 18:10 
GeneralRe: Postback Pin
Matthew Hazlett2-Jan-06 18:12
memberMatthew Hazlett2-Jan-06 18:12 
GeneralRe: Postback Pin
Dan Letecky3-Jan-06 8:29
memberDan Letecky3-Jan-06 8:29 
GeneralVersion 1.0.3 Released Pin
Dan Letecky2-Jan-06 3:46
memberDan Letecky2-Jan-06 3:46 
GeneralVersion 1.0.2 Released Pin
Dan Letecky28-Dec-05 13:48
memberDan Letecky28-Dec-05 13:48 
GeneralEvents always show up at BusinessStartingHour Pin
stephg12327-Dec-05 6:08
memberstephg12327-Dec-05 6:08 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160426.1 | Last Updated 16 Mar 2015
Article Copyright 2005 by Dan Letecky
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid