6. Handling User Actions

DayPilot Lite supports two user actions:

  • clicking a free time cell (you will typically use this action to create a new event)
  • clicking an event (you will typically use this action to show event details)

The actions can be handled on the client (by custom JavaScript code) or on the server (by handling the server event).

PropertyDescriptionTypeDefault value
EventClickHandlingHandling of a click on a calendar event.EventClickHandlingEnumEventClickHandlingEnum.Disabled
TimeRangeSelectedHandlingHandling of a click on a free-time slot.TimeRangeSelectedHandlingTimeRangeSelectedHandling.Disabled
EventClickJavaScriptJavaScript code that should be executed when the user clicks on a calendar event (provided that EventClickHandling is set to JavaScript). The string "{0}" will be replaced with an event ID. Set the value to an empty string to disable the default alert box.string"alert('{0}');"
TimeRangeSelectedJavaScriptJavaScript code that should be executed when the user clicks on a free-time slot (provided that TimeRangeSelectedHandling is set to JavaScript). The string "{0}" will be replaced with the date and time specified in the standard format produced by DateTime.ToString("s") - e.g. "2006-05-15T07:00:00". Set the value to an empty string to disable the default alert box.string"alert('{0}');"

For more about server-side event handling see Server-side event handling.

Usage

The typical action for clicking a free time slot will be creating a new event. You can use the following JavaScript code to redirect the user to a page with new event details:

Set TimeRangeSelectedJavaScript to "document.location='NewEvent.aspx?startingtime={0}';"

In the NewEvent.aspx take the Request.QueryString["startingtime"] value and convert it to DateTime:

DateTime startingTime;
if (Request.QueryString["startingtime"] != null)
  startingTime = Convert.ToDateTime(Request.QueryString["startingtime"]);

Then you can use the value to prefill a form with date and time specification.

DayPilot for JavaScript, ASP.NET WebForms, ASP.NET MVC, Java