2017-04-12 107 views
0

我正在使用DayPilot在每月视图中创建日历。没有合适的方法来覆盖

所以下面这个tutorial,我有这样的:

public class Dpm : DayPilotMonth 
{ 
    MyCalendarEntities db = new MyCalendarEntities(); 

    protected override void OnInit(InitArgs e) // this is where I receive the error 
    { 
     Update(); 
    } 

    protected override void OnFinish() 
    { 
     // only load the data if an update was requested by an Update() call 
     if (UpdateType == CallBackUpdateType.None) 
     { 
      return; 
     } 

     Events = db.Events.ToList(); 

     DataStartField = "StartDate"; 
     DataEndField = "EndDate"; 
     DataTextField = "Event1"; 
     DataIdField = "ID"; 

    } 
} 

我只收到关于OnInit方法的错误,但不是在OnFinish方法,即使在基类中他们几乎宣告了相同:

基类:

public class DayPilotMonth 
{ 
    protected DayPilotMonth(); 


    public string BackColor { get; set; } 

    public string HeaderBackColor { get; set; } 

    public string Id { get; } 

    public string NonBusinessBackColor { get; set; } 
    public DayOfWeek ResolvedWeekStart { get; } 

    public DateTime StartDate { get; set; } 

    public CallBackUpdateType UpdateType { get; } 
    public DateTime VisibleEnd { get; } 
    public DateTime VisibleStart { get; } 

    public WeekStarts WeekStarts { get; set; } 
    protected Controller Controller { get; } 

    protected string DataEndField { get; set; } 

    protected string DataIdField { get; set; } 

    protected string DataStartField { get; set; } 

    protected string DataTextField { get; set; } 
    protected IEnumerable Events { get; set; } 

    public ActionResult CallBack(Controller c); 

    protected virtual void OnBeforeEventRender(BeforeEventRenderArgs e); 
    protected virtual void OnCommand(CommandArgs e); 
    protected virtual void OnEventClick(EventClickArgs e); 
    protected virtual void OnEventMove(EventMoveArgs e); 
    protected virtual void OnEventResize(EventResizeArgs e); 
    protected virtual void OnFinish(); 
    protected virtual void OnInit(InitArgs e); 

    protected virtual void OnPrepare(); 
    protected virtual void OnTimeRangeSelected(TimeRangeSelectedArgs e); 

    protected void Redirect(string url); 
    protected void Update(); 
    protected void Update(object data); 
    protected void Update(CallBackUpdateType type); 
    protected void Update(object data, CallBackUpdateType type); 
} 

我在做什么错了?

+0

难道有两个班,名字'InitArgs'? – Fabjan

+0

事实证明,有!我从来没想过这点。谢谢! –

+0

检查初始化参数命名空间,没有其他想到 – levent

回答

1

添加此使用:

using DayPilot.Web.Mvc.Events.Month; 

甚至更​​好:

protected override void OnInit(DayPilot.Web.Mvc.Events.Month.InitArgs e) {.. 
+0

啊,那工作!非常感谢! –

相关问题