Helpers for DHTMLX Scheduler .NET in Use

There are special helpers in the library, which can be effectively used in any ASP.NET or ASP.NET MVC project. In particular, the helper ‘DHXEventsHelper’ can be applied while creating an event calendar with DHTMLX Scheduler web-control. The benefit from using such a helper is evident because it helps not only reduce and simplify the code, but also averts different errors caused by manual updating of the server-side API.

Let’s consider this helper and the methods it applies.

The helper ‘DHXEventsHelper’ is used to automate actions with the Scheduler events by means of the three methods described below:

1. Bind () - builds an object by assembling values from NameValueCollection (e.g. HttpRequest.Form) and converting them into an appropriate data type.

The 'bind' method has two overloads:

public static object Bind(Type obj, NameValueCollection values);
public static object Bind(Type obj, NameValueCollection values, CultureInfo culture);

It can be used instead of MVC model binder and in any ASP.NET application.


To save data we used to manually build an object by adding query fields:

var changedEvent = new Event();
changedEvent.start_date = DateTime.Parse(context.Request.Form["start_date"], new CultureInfo("en-US"));
changedEvent.end_date = DateTime.Parse(context.Request.Form["end_date"], new CultureInfo("en-US"));
changedEvent.text = context.Request.Form["text"];

 With ‘DHXEventsHelper’ it can be implemented automatically:

var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), context.Request.Form);

2. Update () – updates a model object with the values of another object.

The 'update 'method has two overloads:

public static void Update(object target, object source);
public static void Update(object target, object source, List<string> except);

Example :

In the same way, when you add a new field you have to add a certain code:

default:// "update" // your Update logic
    var updated = data.Events.SingleOrDefault(ev => == action.SourceId);
    updated.text = changedEvent.text;
    updated.start_date = changedEvent.start_date;
    updated.end_date = changedEvent.end_date;

With this helper it can be accomplished much easier:

    var updated = data.Events.SingleOrDefault(ev => == action.SourceId);
    DHXEventsHelper.Update(updated, changedEvent, new List<string>() { "id" });

3. ‘GetOccurrences’ is a helper method used to obtain recurring events in the server-side API. It allows setting the start date and the end date to get a series of events that will happen during this interval. The ‘GetOccurences’ method facilitates the recall of recurring events and you can hardly do without it. A series of recurring events is stored in the database as a single event, recurring rule - in the 'rec_type' field.


var helper = new DHXEventsHelper();
var items = helper.GetOccurrences(new DHXSchedulerDataContext().Recurrings, new DateTime(2012, 11, 10), new DateTime(2012, 12, 10));

 ‘GetOccurrences’ takes 3 parameters:

1. IEnumerable with all events;

2. two dates ‘from’ and ‘to’ to set interval boundaries for the events.

This method will return List<object> with the objects of the same class as in the data source. Single events and recurring instances, which occur within the time interval, will go to List<object>. 

If you find the described helpers and their methods useful, please, share this article with your friends and comment below.



Viktoria Langer

DHTMLX Scheduler .NET product care manager and customer manager since 2012. Interested in ASP.NET and trying to create valuable content.

Recent Blog Posts