You can add, remove, and update events on the client side.

Overview

See also

JavaScript

Event adding

Events can be added to the Calendar using events.add() method.

var e = new DayPilot.Event({start:new DayPilot.Date(), end:(new DayPilot.Date()).addHours(5), value: DayPilot.guid(), text: "New Event", resource:'E'});
dpc.events.add(e);

Event updating

Events can be updated using events.update() method. The object representing the event must be acquired using events.find() or event.findRecurrent().

var e = dpc.events.find('123');
dpc.text('New Event Name'); // update the event text
dpc.client.innerHTML('New Event Name'); // update the event HTML dpc.events.update(e);

Event removing

Events can be removed using events.remove() method. The object representing the event must be acquired using events.find() or event.findRecurrent().

var e = dpc.events.find('123');
dpc.events.remove(e);

ASP.NET WebForms

Event adding

Events can be added to the Calendar using events.add() method.

var e = new DayPilot.Event({start:new DayPilot.Date(), end:(new DayPilot.Date()).addHours(5), value: DayPilot.guid(), text: "New Event", resource:'E'});
dpc.events.add(e).notify();

This example will add a new event called "New Event" and notify the server by firing EventAdd event.

protected void DayPilotCalendar1_EventAdd(object sender, EventAddEventArgs e)
{
  // create the event in the database using custom method
  createEvent(e.Event.Value, e.Event.Start, e.Event.End, e.Event.Resource, e.Event.Text);  // your method for updating the database

  // display a message to the user
  DayPilotCalendar1.UpdateWithMessage("Added.");
}

Event updating

Events can be updated using events.update() method. The object representing the event must be acquired using events.find() or event.findRecurrent().

var e = dpc.events.find('123');
dpc.text('New Event Name');  // update the event text
dpc.events.update(e).notify();

This example will find an event with id "123", update the text and displayed HTML, and notify the server by firing EventUpdate event.

protected void DayPilotCalendar1_EventUpdate(object sender, EventUpdateEventArgs e)
{
  createEvent(e.Event.Value, e.Event.Start, e.Event.End, e.Event.Resource, e.Event.Text); // your method for updating the database

  // display a message to the user
  DayPilotCalendar1.UpdateWithMessage("Updated.");
}

Event removing

Events can be removed using events.remove() method. The object representing the event must be acquired using events.find() or event.findRecurrent().

var e = dpc.events.find('123');
dpc.events.remove(e).notify();

This example will find an event with id "123", remove it, and notify the server by firing EventRemove event.

protected void DayPilotCalendar1_EventRemove(object sender, EventRemoveEventArgs e)
{
removeEvent(e.Event.Value); // your method for updating the database

// display a message to the user DayPilotCalendar1.UpdateWithMessage("Deleted."); }