Hi,
The ItemCreated, ItemModified, ItemDeleted events are not raised on the client if AutoPostBack is enabled for the control. The validating events - ItemCreating, ItemModifying, etc. are still raised - that's why you're able to handle ItemCreating, but not ItemModified.
What you're trying to do can be achieved by either:
1. using the ItemModifying event instead of ItemModified, check if the location is changed, and apply the correct CSS class by using the
calendar.editItem method:
function itemModifying(sender, args) {
if (args.get_changes().location) {
var loc = sender.getResourceById(args.get_changes().location);
if (loc.name == "Loc1")
sender.editItem(args.get_item(), { cssClass: "Loc1" });
else if (loc.name == "Loc2")
sender.editItem(args.get_item(), { cssClass: "Loc2" });
// etc...
}
}
or by
2. disabling AutoPostBack - in that case you'll need to postback the control yourself when needed - i.e. from the client-side ItemCreated, ItemModified, ItemDeleted, or in response to some user action. To postback the control you can use this code:
function postbackCalendar() {
var calendar = $find("<%= Calendar1.ClientID %>");
if (calendar) {
calendar.postback();
}
}
//...
function itemCreated(sender, args) {
// some processing...
// postback the control
postbackCalendar();
}
//...
Regards,
Lyubo