The client-side event-handling API has two modes that can be switched using .api property:
http://api.daypilot.org/daypilot-scheduler-api/
All DayPilot versions that include an integrated server-side part (ASP.NET WebForms, MVC, Java) use .api=1. These versions will support api=2 in the near future but at this moment you can only use api=1 (api=2 will break the event handlers set from the server side).
You should check the bottom of the API doc page for the api=1 syntax:
http://api.daypilot.org/daypilot-scheduler-ontimerangeselected/
The standalone JavaScript version uses .api=2 by default and the following example will work. It is copied from the demo at http://javascript.daypilot.org/demo/scheduler/
dp.onTimeRangeSelected = function (args) {
var name = prompt("New event name:", "Event");
dp.clearSelection();
if (!name) return;
var e = new DayPilot.Event({
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: name
});
dp.events.add(e);
dp.message("Created");
};