Thanks a lot to be so active on this forum. You helped me a lot, so both of custom lightbox and event color problems are resolved.
Now, my problem occurs when I try to save data and get it back from database.
I will show source code first and explain the problem after :
First I add some filed in the lightbox this way :
Default.aspx.cs
[code] var select1 = new LightboxSelect(“textColor”, “Couleur (texte)”);
var items1 = new List(){
new { key = “white”, label = “Blanc” },
new { key = “red”, label = “Rouge” },
new { key = “yellow”, label = “Jaune” },
new { key = “blue”, label = “Bleu” }
};
select1.AddOptions(items1);
Scheduler.Lightbox.Add(select1);
var select2 = new LightboxSelect("color", "Couleur (événement)");
var items2 = new List<object>(){
new { key = "white", label = "Blanc" },
new { key = "red", label = "Rouge" },
new { key = "yellow", label = "Jaune" },
new { key = "blue", label = "Bleu" }
};
select2.AddOptions(items2);
Scheduler.Lightbox.Add(select2);[/code]
Save.ashx.cs
[code]using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DHTMLX.Common;
using DHTMLX.Helpers;
using System.Globalization;
namespace SchedulerNetAsp
{
///
///
public class Save : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var action = new DataAction(context.Request.Form);
var data = new SchedulerDataContext();
try
{
var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), context.Request.Form);//create event object from request
switch (action.Type)
{
case DataActionTypes.Insert: // define here your Insert logic
data.Events.InsertOnSubmit(changedEvent);
break;
case DataActionTypes.Delete: // define here your Delete logic
changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
data.Events.DeleteOnSubmit(changedEvent);
break;
default:// "update" // define here your Update logic
var updated = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
//update "updated" object by changedEvent's values, 'id' should remain unchanged
DHXEventsHelper.Update(updated, changedEvent, new List<string>() { "id" });
break;
}
data.SubmitChanges();
action.TargetId = changedEvent.id;
}
catch
{
action.Type = DataActionTypes.Error;
}
context.Response.ContentType = "text/xml";
context.Response.Write(new AjaxSaveResponse(action).ToString());
}
public bool IsReusable
{
get
{
return false;
}
}
}
}[/code]
Now the problem is that custom fields values are not saved in the database even if columns like color and textColor are created in the Events table…
How can I insert and get those values ?
Thanks !