DayPilot Forums

DayPilot is the best open-source Outlook-like calendar control for ASP.NET.
DayPilot Pro Demo (Calendar control)
» DayPilot Pro live demo (Calendar control)
DayPilot Pro Demo (Scheduler control)
» DayPilot Pro live demo (Scheduler control)
Home » Bugs » JavaScript Error when I add an event.

JavaScript Error when I add an event.

Error : Microsoft JScript runtime error: 'rows[...].cells' is null or not an object

I am using DayPilot Pro 4.0.1205.1

Here is my code :

hc.InsertEvents("new event", e.Start, e.End, Convert.ToInt32(e.ColumnId), false, Page.User.Identity.Name);
DayPilotScheduler1.DataSource = hc.GetEvents();
DayPilotScheduler1.DataBind();
DayPilotScheduler1.Update();

peter cli - 10/3/2007 2:48:05 AM
Thanks for reporting the bug.

Could you please send me your .aspx and aspx.cs files to daypilot @ annpoint.com? I would like to test it with your code because it doesn't appear in the demo.
Dan Letecky - 10/3/2007 4:05:11 PM
This error was caused by the following code:
    protected void Page_Load(object sender, EventArgs e)
{
DayPilotScheduler1.Resources.Add("One", "1");
DayPilotScheduler1.Resources.Add("Two", "2");
DayPilotScheduler1.Resources.Add("Three", "3");

DayPilotScheduler1.DataSource = getEvents();
DataBind();
}

The Resources collection is persisted across requests using ViewState and calling this code during PostBack requests adds the resources again to the collection. The internal event-arranging code works with an updated Resources collection (with doubled items) but the client-side code works with the original collection (CallBack action is not able to update the Resources collection, only the events). The Resources initialization code should be put it inside "if (!IsPostBack)" block:

    protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DayPilotScheduler1.Resources.Add("One", "1");
DayPilotScheduler1.Resources.Add("Two", "2");
DayPilotScheduler1.Resources.Add("Three", "3");

// having the following two lines outside of the conditional block
// will not produce an error but it will mean extra database
// lookup
DayPilotScheduler1.DataSource = getEvents();
DataBind();
}
}

I've made changes to DayPilot code that will prevent this JavaScript error even if you extend the Resources collection during callback.

But remember that if an existing Resources collection item is changed during callback (e.g. if item "Two" is replaced with "Four") it will still confuse the client during update.

Dan Letecky - 10/3/2007 5:01:58 PM
And, the fix will be included in 4.1 release.
Dan Letecky - 10/3/2007 5:02:54 PM
Post reply