The Monthly Calendar supports automatic event reloading (in specified intervals).

AutoRefresh is disabled by default. You can enable it using AutoRefreshEnabled property.

If enabled, AutoRefresh will fire Command event on the server side with the value of AutoRefreshCommand as the command name.

Configuration properties:

  • AutoRefreshEnabled (bool)
  • AutoRefreshInterval (int) - number of seconds between automatic reloads
  • AutoRefreshMaxCount (int) - maximum number of automatic reloads
  • AutoRefreshCommand (string) - a command value that will be passed to Command event when requesting a reload

ASP.NET WebForms

.aspx

<DayPilot:DayPilotMonth 
  ID="DayPilotMonth1" 
  runat="server" 
  ...
  OnCommand="DayPilotMonthr1_Command" 
  AutoRefreshEnabled="true"
  AutoRefreshInterval="10"
  AutoRefreshMaxCount="12"
  />

.aspx.cs

protected void DayPilotMonth1_Command(object sender, CommandEventArgs e)
{
  switch (e.Command)
  {
      case "refresh":
          setDataSourceAndBind();
          DayPilotCalendar1.DataBind();
          DayPilotCalendar1.UpdateWithMessage("Events refreshed automatically");
          break;
  }
}

ASP.NET MVC

View

@Html.DayPilotMonth("dpm", new DayPilotMonthConfig()
{
  BackendUrl = ResolveUrl("~/Month/Backend"),
  ...
  AutoRefreshEnabled = true,
  AutoRefreshInterval = 10,
  AutoRefreshMaxCount = 5
})

Controller

protected override void OnCommand(CommandArgs e)
{
  switch (e.Command)
  {
      case "refresh":
          UpdateWithMessage("Refreshed");
          break;
  }
}

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

  Events = new EventManager(Controller).FilteredData(VisibleStart, VisibleEnd).AsEnumerable();  // your method

  DataStartField = "start";
  DataEndField = "end";
  DataTextField = "text";
  DataIdField = "id";
}

Demo

JavaScript

AutoRefresh is not available for DayPilot Pro for JavaScript.