DayPilot Knowledge Base

AJAX Calendar/Scheduling Controls
DayPilot Pro (AJAX Calendar Control)
» DayPilot ASP.NET Calendar
DayPilot Pro (AJAX Monthly Calendar Control)
» DayPilot ASP.NET Monthly Calendar
DayPilot Pro (AJAX Scheduler Control)
» DayPilot ASP.NET Scheduler
DayPilot » Knowledge Base » How to use DayPilot Pro for MVC 3 with Razor view engine

How to use DayPilot Pro for MVC 3 with Razor view engine

Last revision: Sep 9, 2011

DayPilot Pro for ASP.NET MVC is compatible with MVC 3 and it supports the Razor view engine.

See also:

Here is an example for DayPilot Calendar:

1. Add a reference to DayPilot.Web.Mvc.dll to the project or add it to the Bin directory of the web application.

2. In order to enable the HTML helpers, add the following DayPilot.Web.Mvc to the namespaces in Views/web.config:

<configuration>
  <system.web.webPages.razor>
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        ...
        <add namespace="DayPilot.Web.Mvc" />
        ...
      </namespaces>
    </pages>
  </system.web.webPages.razor>
</configuration>

3. Now you can use the DayPilot helpers in the Razor views (Index.cshtml).

@using DayPilot.Web.Mvc.Events.Calendar;
@using DayPilot.Web.Mvc.Enums.Calendar;

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Index</h2>

@Html.DayPilotCalendar("dpc", new DayPilotCalendarConfig
{
    BackendUrl = Url.Content("~/Backend/Calendar"),
    EventResizeHandling = EventResizeHandlingType.CallBack,
    EventMoveHandling = EventMoveHandlingType.CallBack,
    TimeRangeSelectedHandling = TimeRangeSelectedHandlingType.CallBack,
    ViewType = DayPilot.Web.Mvc.Enums.Calendar.ViewType.Week,
    Days = 7,
    StartDate = DayPilot.Web.Mvc.Utils.Week.FirstDayOfWeek(),
    BusinessBeginsHour = 9,
    BusinessEndsHour = 18,
    CssClassPrefix = "calendar_silver_",
    EventArrangement = ArrangementType.Full
})

Related

How to show an event calendar in ASP.NET MVC 3 Razor
Event Calendar for jQuery (ASP.NET MVC)
How to open a new event dialog using TimeRangeSelected event (modal.js)
How to show the selected date using a Label control