A quick start (boilerplate) project for DayPilot Pro ASP.NET MVC Scheduler.

  • Visual Studio project.

  • ASP.NET MVC 4 added using NuGet.

  • DayPilot Pro is added as a local reference.

  • Single view with DayPilot Scheduler @Html.DayPilotScheduler()

  • Simple backend that adds a few static resources and events.

This is a blank project without any customizations applied. For more details on Scheduler configuration (loading resources, loading events, creating events, moving events, etc.) please see the detailed tutorial:

License

Licensed for testing and evaluation purposes. You can use the source code of the tutorial if you are a licensed user of DayPilot Pro for ASP.NET MVC.

Requirements

  • Visual Studio

  • .NET Framework 4.5+

MVC View

Views/Home/Index.cshtml

@section TitleContent {
    ASP.NET MVC 4 Scheduler
}

<h1>Scheduler</h1>

<script src="~/Scripts/DayPilot/daypilot-all.min.js"></script>

@Html.DayPilotScheduler("dp", new DayPilotSchedulerConfig()
{
    BackendUrl = @Url.Action("Scheduler", "Backend"),
    StartDate = new DateTime(2017, 1, 1),
    Days = 31,
    Scale = TimeScale.Day,
    TimeHeaders = new TimeHeaderCollection()
    {
        new TimeHeader(GroupBy.Month, "MMMM yyyy"),
        new TimeHeader(GroupBy.Day),
    },
    EventMoveHandling = EventMoveHandlingType.Notify
})

Home Controller

Controllers/HomeController.cs

using System.Web.Mvc;

namespace TestMvc4.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }
    }
}

Backend Controller

Controllers/BackendController.cs

using System.Web.Mvc;
using DayPilot.Web.Mvc;
using DayPilot.Web.Mvc.Enums;
using DayPilot.Web.Mvc.Events.Scheduler;

namespace TestMvc4.Controllers
{
    [HandleError]
    public class BackendController : Controller
    {
        public ActionResult Scheduler()
        {
            return new Dps().CallBack(this);
        }

    }

    class Dps : DayPilotScheduler
    {
        protected override void OnInit(InitArgs e)
        {
            // load resources
            Resources.Add("Resource 1", "R1");
            Resources.Add("Resource 2", "R2");

            // load events
            Events = new DataManager().GetData();
            DataIdField = "Id";
            DataTextField = "Text";
            DataResourceField = "ResourceId";
            DataStartField = "Start";
            DataEndField = "End";


            // request a full update (resources and events)
            Update(CallBackUpdateType.Full);
        }

        protected override void OnEventMove(EventMoveArgs e)
        {
            new DataManager().MoveEvent(e.Id, e.NewStart, e.NewEnd, e.NewResource);
        }
    }
}

NuGet Dependencies

packages.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.AspNet.Mvc" version="4.0.40804.0" targetFramework="net452" />
  <package id="Microsoft.AspNet.Razor" version="2.0.20710.0" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net452" />
  <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net452" developmentDependency="true" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
</packages>

Upgrading DayPilot Pro Version

This tutorial includes DayPilot Pro for ASP.NET MVC 8.3 SP1 (build 8.3.5852). 

This is how you can upgrade to the latest DayPilot Pro version:

  1. Download the latest DayPilot Pro trial version. You can get a trial version from the Try page.

  2. Copy Binary/Mvc4/DayPilot.Web.Mvc.dll from the download package to Lib/DayPilot.Web.Mvc.dll (overwrite the existing file).

  3. Copy Scripts/daypilot-all.min.js from the download package to Scripts/DayPilot/daypilot-all.min.js in the project (overwrite the existing file).

You may want to slightly modify the client-side script reference to prevent the browser from using the previous cached version. Adding ?v=3582 query string with the version number will work:

Views/Home/Index.cshtml

<script src="~/Scripts/DayPilot/daypilot-all.min.js?v=3582"></script>