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
- StartDate
- Cells (BeforeCellRender)
- Day Headers (incl. BeforeHeaderRender)
Message
You can display custom message using UpdateWithMessage() method:
DayPilotMonth1.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.
Example 1: Sending a simple string
.aspx
<daypilot:daypilotMonth id="DayPilotMonth1" runat="server" ... AfterRenderJavaScript="afterRender(data);" />
Server-side code (.aspx.cs):
protected void DayPilotMonth1_TimeRangeSelected(object sender, TimeRangeSelectedEventArgs e) { // ... update database DayPilotMonth1.DataBind(); DayPilotMonth1.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 DayPilotMonth1_TimeRangeSelected(object sender, TimeRangeSelectedEventArgs e) { // ... update database DayPilotMonth1.DataBind(); Hashtable ht = new Hashtable(); ht["message"] = "Event moved."; ht["id"] = e.Value; DayPilotMonth1.Update(ht); }
Server-side template (.aspx):
<daypilot:daypilotMonth id="DayPilotMonth1" 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
- ViewType
- StartDate
- WeekStarts
- ShowWeekend
- Weeks
- HeaderBackColor
- BackColor
- NonBusinessBackColor
- CssOnly
- Cells (BeforeCellRender)
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.
Example 1: Sending a simple string
MVC View
@Html.DayPilotMonth("dpm", new DayPilotMonthConfig { BackendUrl = ResolveUrl("~/Month/Backend"), ... AfterRenderJavaScript = "afterRender(data, isCallBack)" }) <script type="text/javascript"> function afterRender(data) { if (data) { document.getElementById('messageDiv').innerHTML = data; } } </script>
MVC Controller (Dpm 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.DayPilotMonth("dpm", new DayPiloMonthConfig { BackendUrl = ResolveUrl("~/Month/Backend"), ... AfterRenderJavaScript = "afterRender(data, isCallBack)" }) <script type="text/javascript"> function afterRender(data) { if (data) { document.getElementById('messageDiv').innerHTML = data.message; } } </script>
MVC Controller (Dps 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); }