All client-side callback methods have an extra parameter (data) that will allow you to send additional information to the server.

Methods Affected

ASP.NET WebForms

Smart Object Handling

  • You can send any kind of object (int, string, Date, array, object...).
  • The JavaScript object is accessible using a string indexer (e.g. e.Data["property"]).
  • You can access the full hierarchy without casting the individual levels (e.g. e.Data["property"]["item"]["subitem"]).
  • The JavaScript array is accessible using a int indexer (e.g. e.Data[0]).
  • You can convert the parameter value directly by casting in most cases (e.g. (string) e.Data will convert int value to string).

The "data" parameter will be translated into a JsonData class instance. JsonData is a polymorphic element that mimics an untyped JavaScript object.

Depending on the "data" content, it can be accessed in various ways:

  • string: (string) e.Data
  • integer: (int) e.Data
  • Date: (DateTime) e.Data
  • DayPilot.Date: (DateTime) e.Data
  • array: e.Data[0]
  • object with properties: e.Data["property"]
  • object hierarchy: e.Data["item"]["subitem"]

Example 1 (string)

Client side:

var state = "on";
dps1.eventClickCallBack(e, state);

Server side:

protected void DayPilotScheduler1_EventClick(object sender, DayPilot.Web.Ui.Events.EventClickEventArgs e)
{
   string state = (string) e.Data;
}

Example 2 (Date object)

Date object always sends its UTC value (not local time).

Client side:

var date = new Date();
dps1.eventClickCallBack(e, date);

Server side:

protected void DayPilotScheduler1_EventClick(object sender, DayPilot.Web.Ui.Events.EventClickEventArgs e)
{
   // be careful, this date doesn't correspond to the client 
   // local time unless you are in +00 time zone
   DateTime date = (DateTime) e.Data; 
}

Example 3 (DayPilot.Date object)

DayPilot.Date object ignores the time zones and sends exactly what you supply. The constructor (new DayPilot.Date()) creates a new date using the current local time.

Client side:

var date = new DayPilot.Date();
dps1.eventClickCallBack(e, date);

Server side:

protected void DayPilotScheduler1_EventClick(object sender, DayPilot.Web.Ui.Events.EventClickEventArgs e)
{
   DateTime date = (DateTime) e.Data;  
}

Example 5 (array)

Client side:

var myArray = ['a', 'b', 'c'];
dps1.eventClickCallBack(e, myArray);

Server side:

protected void DayPilotScheduler1_EventClick(object sender, DayPilot.Web.Ui.Events.EventClickEventArgs e)
{
   string a = (string) e.Data[0];  
}

Example 4 (object)

You can send any object. It will be accessible as a Dictionary hieararchy.

Client side:

var o = {};
o.name = "name";
o.value = "value";
o.child = {};
o.child.name = "child name";
o.child.value = "child value";
dps1.eventClickCallBack(e, o);

Server side:

protected void DayPilotScheduler1_EventClick(object sender, DayPilot.Web.Ui.Events.EventClickEventArgs e)
{
   string childValue = (string) e.Data["child"]["value"];
}

See Also