There are two ways to do this:
- If it's possible to move the calculation to the client side: Switch to JavaScript handling, check if the move is allowed and call your action - either dpc1.eventMoveCallBack() or alert() with your message.
- If you want to keep in on the server side: Check if the action is allowed in the EventMove handler. If it's not, call DayPilotCalendar1.Update(message) without changing the database. "message" should be a Hashtable object with your own message details. Handle AfterRenderJavaScript and check the "data" variable and show the message accordingly.
Both these events are fired after the move is finished (the event is dropped at the target location).
Example of #2:
YourPage.aspx
DayPilot tag:
... AfterRender="checkMessage(data)" ...
JavaScript:
<script>
function checkMessage(data) {
if (data) {
if (data.type == "notallowed") {
alert(data.message);
}
}
}
</script>
YouPage.aspx.cs:
protected void DayPilotCalendar1_EventMove(object sender, EventMoveEventArgs e)
{
Hashtable msg = null;
if (isAllowed(e)) {
// update the db
// ...
}
else {
msg = new Hashtable();
msg["type"] = "notallowed";
msg["message"] = "You are not allowed to move this event.";
}
DayPilotCalendar1.DataSource = getYourData();
DayPilotCalendar1.DataBind();
DayPilotCalendar1.Update(msg);
}
A working example of a similar AfterRender code can be found in the DayPilot Pro package, in Demo/Calendar/Default.aspx (.cs).