In order to update the scheduler on the client side during a CallBack it is necessary to call Update() method.

ASP.NET WebForms

Update Type

public void Update(CallBackUpdateType updateType);

CallBackUpdateType is an enum with the following values:

  • Auto
  • EventsOnly
  • Full
  • None

Auto is the default value. It selects the update mode depending on values that were actually changed during the CallBack.

Full value reloads both events and headers.

Properties

Always updated (None, EventsOnly, Full):

  • ClientState
  • SelectedEvents
  • Message [UpdateWithMessage()]

EventsOnly update

  • Events (DataSource)

Full update

  • Cells (BeforeCellRender)
  • CellDuration
  • Columns (incl. BeforeHeaderRender)
  • CornerHtml
  • CornerBackColor
  • Days
  • HeaderLevels
  • StartDate
  • Time Headers (BeforeTimeHeaderRender)
  • TimeHeaderCellDuration
  • ViewType

Message

You can display custom message using UpdateWithMessage() method:

DayPilotCalendar1.UpdateWithMessage("Event moved");

Sending custom data to the client

It is possible to send a custom data from the CallBack event handler back to the client. This will allow showing custom messages after the event was handled.

callback data

Example 1: Sending a simple string

.aspx

<daypilot:daypilotCalendar 
  id="DayPilotCalendar1" 
  runat="server" 
  ...
  AfterRenderJavaScript="afterRender(data);"         
/>

Server-side code (.aspx.cs):

protected void DayPilotCalendar1_TimeRangeSelected(object sender, TimeRangeSelectedEventArgs e)
{
  // ... update database

  DayPilotCalendar1.DataBind();
  DayPilotCalendar1.Update("New event created.");
}

Client-side code (.aspx):

function afterRender(data) {
    if (data) {
         document.getElementById('messageDiv').innerHTML = data;
    }
}

Example 2: Sending a dictionary

Server-side code (.aspx.cs):

protected void DayPilotCalendar1_TimeRangeSelected(object sender, TimeRangeSelectedEventArgs e)
{
  // ... update database

  DayPilotCalendar1.DataBind();

  Hashtable ht = new Hashtable();
  ht["message"] = "Event moved.";
  ht["id"] = e.Value;
  DayPilotCalendar1.Update(ht);
}

Server-side template (.aspx):

<daypilot:daypilotCalendar 
  id="DayPilotCalendar1" 
  runat="server" 
  ...
  AfterRenderJavaScript="afterRender(data);"         
/>

Client-side code (.aspx):

function afterRender(data) {
    if (data) {
        document.getElementById('messageDiv').innerHTML = data.message + " (id " + data.id + ")";
    }
}

ASP.NET MVC

Update Type

public void Update(CallBackUpdateType updateType);

CallBackUpdateType is an enum with the following values:

  • EventsOnly
  • Full
  • None

EventsOnly is the default value. It updates the events (Events property).

Full value reloads events, resources, cells and headers (including other selected properties, see below).

Properties

Always updated (None, EventsOnly, Full):

  • Message [UpdateWithMessage()]

EventsOnly update

  • SelectedEvents
  • EventSortExpression
  • Events (DataSource)

Full update

  • Cells (BeforeCellRender)
  • Columns (incl. BeforeHeaderRender)
  • Time Headers (BeforeTimeHeaderRender)
  • CssOnly
  • CssClassPrefix
  • StartDate
  • Days
  • CellDuration
  • HeaderLevels
  • ViewType
  • CornerHtml
  • CornerBackColor
  • DayBeginsHour
  • DayEndsHour
  • TimeHeaderCellDuration

Message

You can display custom message using UpdateWithMessage() method:

UpdateWithMessage("Event moved");

The default update type is EventsOnly.

Sending custom data to the client

It is possible to send a custom data from the CallBack event handler back to the client. This will allow showing custom messages after the event was handled.

callback data

Example 1: Sending a simple string

MVC View

@Html.DayPilotCalendar("dpc", new DayPilotCalendarConfig {
  BackendUrl = ResolveUrl("~/Calendar/Backend"),
  ...
  AfterRenderJavaScript = "afterRender(data, isCallBack)"
})

<script type="text/javascript">
  function afterRender(data) {
    if (data) {
         document.getElementById('messageDiv').innerHTML = data;
    }
  }
</script>

MVC Controller (Dpc class)

protected override void OnEventResize(EventResizeArgs ea)
{
  new EventManager(Controller).EventMove(ea.Id, ea.NewStart, ea.NewEnd);
  Update("Updated");
}

Example 2: Sending a dictionary

MVC View

@Html.DayPilotCalendar("dpc", new DayPilotCalendarConfig {
  BackendUrl = ResolveUrl("~/Calendar/Backend"),
  ...
  AfterRenderJavaScript = "afterRender(data, isCallBack)"
})

<script type="text/javascript">
  function afterRender(data) {
    if (data) {
         document.getElementById('messageDiv').innerHTML = data.message;
    }
  }
</script>

MVC Controller (Dpc class)

protected override void OnEventResize(EventResizeArgs ea)
{
  new EventManager(Controller).EventMove(ea.Id, ea.NewStart, ea.NewEnd);

  Hashtable ht = new Hashtable();
  ht["message"] = "Event resized.";
  ht["id"] = e.Value;

  Update(ht);
}