Click here to Skip to main content
15,790,243 members
Articles / Web Development / HTML

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

Rate me:
Please Sign up or sign in to vote.
4.86/5 (120 votes)
9 May 2016Apache5 min read 467.5K   9K   391   89
A good-looking ASP.NET control that shows events visually arranged in a day calendar. Includes design-time support and data binding.

Image 1


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, Edge, Safari, Opera).
  • Visual Studio 2010/2012/2013/2015
  • 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:

Image 2

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)

Image 3

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)

Image 4

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

See also:

CSS Theme Styling (4.0)

Image 5

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)

Image 6

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.

Drag and Drop (5.0)

Image 7

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 [].

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

Written By
Czech Republic Czech Republic
My open-source event calendar/scheduling web UI components:

DayPilot for JavaScript, Angular, React and Vue

Comments and Discussions

QuestionShifted columns/data Pin
Alla25528-Mar-16 4:50
Alla25528-Mar-16 4:50 
Questionchange Calendar type (Jalali) Pin
MB Seifollahi2-Jun-14 20:52
professionalMB Seifollahi2-Jun-14 20:52 
BugTypo in History Pin
Jani Giannoudis15-May-14 10:24
Jani Giannoudis15-May-14 10:24 
GeneralRe: Typo in History Pin
Dan Letecky15-May-14 11:08
Dan Letecky15-May-14 11:08 
QuestionLicense Question Pin
sandeegk779-Aug-13 7:26
sandeegk779-Aug-13 7:26 
AnswerRe: License Question Pin
Dan Letecky11-Aug-13 23:29
Dan Letecky11-Aug-13 23:29 
GeneralMy vote of 5 Pin
Member 446923429-Apr-13 10:45
Member 446923429-Apr-13 10:45 
GeneralRe: My vote of 5 Pin
Dan Letecky29-Apr-13 21:15
Dan Letecky29-Apr-13 21:15 
Question404 to download page Pin
ASUS300026-Apr-13 6:06
ASUS300026-Apr-13 6:06 
AnswerRe: 404 to download page Pin
Dan Letecky26-Apr-13 6:15
Dan Letecky26-Apr-13 6:15 
GeneralMy vote of 5 Pin
Jerry OLoughlin11-Mar-13 7:34
Jerry OLoughlin11-Mar-13 7:34 
GeneralRe: My vote of 5 Pin
Dan Letecky11-Mar-13 22:22
Dan Letecky11-Mar-13 22:22 
Questionquestion Pin
kiquenet.com11-Mar-13 2:46
professionalkiquenet.com11-Mar-13 2:46 
AnswerRe: question Pin
Dan Letecky14-Mar-13 11:29
Dan Letecky14-Mar-13 11:29 
GeneralGreat Pin
Usman59925-Jun-12 8:51
Usman59925-Jun-12 8:51 
GeneralRe: Great Pin
Dan Letecky26-Jun-12 5:34
Dan Letecky26-Jun-12 5:34 
GeneralI have some question of your daypilot [modified] Pin
gavin_11629-Aug-10 16:54
gavin_11629-Aug-10 16:54 
QuestionIntegrate With Real Time Exchange Server Pin
Clement Albert6-May-08 3:12
Clement Albert6-May-08 3:12 
AnswerRe: Integrate With Real Time Exchange Server Pin
Dan Letecky13-May-08 4:36
Dan Letecky13-May-08 4:36 
GeneralLicense question Pin
arcb17-Jan-08 21:08
arcb17-Jan-08 21:08 
AnswerRe: License question Pin
Dan Letecky18-Jan-08 10:02
Dan Letecky18-Jan-08 10:02 
GeneralFor Windows Forms Pin
can kayacan28-Sep-07 0:53
can kayacan28-Sep-07 0:53 
GeneralRe: For Windows Forms Pin
Dan Letecky28-Sep-07 6:56
Dan Letecky28-Sep-07 6:56 
GeneralExtracting Pin
ClaudeX7-Jun-07 0:40
ClaudeX7-Jun-07 0:40 
GeneralRe: Extracting Pin
Dan Letecky8-Jun-07 22:56
Dan Letecky8-Jun-07 22:56 

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.