search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Help with building ASP.NET event calendar

Asked by Anonymous
10 years ago.

Hello.
I am trying to build an event calendar using ASP.net for my organization. The article I used for reference is http://code.daypilot.org/10607/monthly-event-calendar-for-asp-net-mvc-and-jquery-open-source

I have followed the instructions to the letter but I keep getting an error:

Error 1 The type or namespace name 'Event' could not be found (are you missing a using directive or an assembly reference?

What am I doing wrong?

Here are the code blocks of my application:

1)Index

@{ ViewBag.Title = "AJAX Monthly Event Calendar for ASP.NET MVC"; }

<h2>ADE R and T Event Calendar</h2>

<script src="@Url.Content("~/Scripts/DayPilot/daypilot-all.min.js")" type="text/javascript"></script>

@Html.DayPilotMonth("dp", new DayPilotMonthConfig
{
BackendUrl = Url.Content("~/Home/Backend"),
EventMoveHandling = DayPilot.Web.Mvc.Events.Month.EventMoveHandlingType.CallBack,
EventResizeHandling = DayPilot.Web.Mvc.Events.Month.EventResizeHandlingType.CallBack,
TimeRangeSelectedHandling = DayPilot.Web.Mvc.Events.Month.TimeRangeSelectedHandlingType.JavaScript,
TimeRangeSelectedJavaScript = "dp.timeRangeSelectedCallBack(start, end, { name: prompt('New Event Name:', 'New Event') });"
})

2) HomeController.CS

using System;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DayPilot.Web.Mvc;
using DayPilot.Web.Mvc.Events.Month;

namespace Calendar1.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}

public ActionResult Backend()
{
return new Dpm().CallBack(this);
}

class Dpm : DayPilotMonth
{
protected override void OnInit(InitArgs e)
{
var dbo = new DataClasses1DataContext();
Events = from ev in dbo.events select ev;

DataIdField = "EventID";
DataTextField = "EventText";
DataStartField = "EventStart";
DataEndField = "EventEnd";
Update();
}
protected override void OnEventMove(EventMoveArgs e)
{
var dbo = new DataClasses1DataContext();
Events = from ev in dbo.events select ev;

var toBeResized = (from ev in dbo.events where ev.EventID == Convert.ToInt32(e.Id) select ev).First();
toBeResized.EventStart = e.NewStart;
toBeResized.EventEnd = e.NewEnd;
dbo.SubmitChanges();
Update();
}
protected override void OnEventResize(EventResizeArgs e)
{
var dbo = new DataClasses1DataContext();
Events = from ev in dbo.events select ev;

var toBeResized = (from ev in dbo.events where ev.EventID == Convert.ToInt32(e.Id) select ev).First();
toBeResized.EventStart = e.NewStart;
toBeResized.EventEnd = e.NewEnd;
dbo.SubmitChanges();
Update();
}
protected override void OnTimeRangeSelected(TimeRangeSelectedArgs e)
{
var dbo = new DataClasses1DataContext();
Events = from ev in dbo.events select ev;

var toBeCreated = new Event { EventStart = e.Start, EventEnd = e.End, text = (string)e.Data["name"] };
dbo.events.InsertOnSubmit(toBeCreated);
dbo.SubmitChanges();
Update();
}

public object toBeCreated { get; set; }
}
}
}

3) Web.config

<?xml version="1.0"?>

<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="DayPilot.Web.Mvc"/>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="Calendar1" />
</namespaces>
</pages>
</system.web.webPages.razor>

<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>

<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>

I am using Visual Studio 2013. Are there any changes I need to make to the code? Most of it I copy-pasted from the article used for reference.

I apologize if the question is too long. Thanks in advance!

Answer posted by Dan Letecky [DayPilot]
10 years ago.

Have you added a reference to DayPilot.Web.Mvc.dll? If you are using a "web site" project type it's enough to copy the dll to the bin directory. For compiled projects (default for MVC) you need to add a reference to the dll in the visual studio.

If it still doesn't work try running the sample project attached to the article and compare the settings with your project.

If it doesn't help either, let me know.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.