C# DayPilot-在EventClick上返回新视图
我目前正试图在我的项目上实现DayPilot Lite MVC。我已经设置了我的事件,它们是可点击的(通过调试语句测试)。然而,我要做的是处理单击并使用根据我单击的事件id构建的ViewModel加载新视图C# DayPilot-在EventClick上返回新视图,c#,asp.net-mvc,daypilot,C#,Asp.net Mvc,Daypilot,我目前正试图在我的项目上实现DayPilot Lite MVC。我已经设置了我的事件,它们是可点击的(通过调试语句测试)。然而,我要做的是处理单击并使用根据我单击的事件id构建的ViewModel加载新视图 public ActionResult Booking() { ApplicationDbContext db = new ApplicationDbContext(); int id = Dpc.eventID; if (id ==
public ActionResult Booking()
{
ApplicationDbContext db = new ApplicationDbContext();
int id = Dpc.eventID;
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Lesson lesson = db.Lessons.Find(id);
if (lesson == null)
{
return HttpNotFound();
}
return View(lesson);
}
class Dpc : DayPilotCalendar
{
public int eventID;
protected override void OnInit(InitArgs e)
{
ApplicationDbContext db = new ApplicationDbContext();
Events = from ev in db.Lessons select ev;
DataIdField = "ClassID";
DataTextField = "ClassLevel";
DataStartField = "ClassStartDate";
DataEndField = "ClassEndDate";
Update();
}
protected override void OnEventClick(EventClickArgs e)
{
//Test to check the method was firing
Debug.WriteLine("Hey I clicked you");
//Parse the event ID for processing
eventID = int.Parse(e.Id);
//Redirect to the booking page
Redirect("Schedule/Booking");
}
}
当我尝试编写Booking方法时,它告诉我Dpc.eventID需要一个对象引用。我已尝试将类和变量公开,但错误仍然存在。我无法将eventClick设置为公共,因为这样我就无法覆盖原始设置。我之所以使用重定向,是因为如果我尝试任何其他链接,它也会因为同样的原因失败。我猜这是因为它是一个非继承的子类,但是如果它的成员属性具有公共作用域,我是否仍然能够访问它们