Error Detection on Drag-Drop

I am using the dataprocessor to call an asp script to update a category’s parentID when an item is moved in the tree. This all works but I am trying to put in error handling in case anything happens in the DB or ASP. How to I tell Tree not to complete the drop if the server side processor fails? That I can tell none of the routines have the original node the item was in. BTW, this is all DnD in the same tree and there is only one tree on the page.

As I said, it all works but if I manually force an error, I don’t know how to test for the error condition being returned and cancel the drop action in the tree so the category remains where it was in the tree. Reloading the tree isn’t desirable either as the tree can be rather lengthly.

The ASP script checks that the source ID is a valid row, the destination is a valid row and both exist and the category can be dropped onto it. This prevents the category from being dropped into a sub-category of itself which can easily happen on accident. If any of these conditions fails the server side checks, the ASP script returns a “CatMoveError” with a description of the error as to why it failed.

This is what I have so far…

<script language="javascript" type="text/javascript">
function reloadFromArea() {

function CatTreeOndblclick(id) {
	document.location.href = "catedit.asp?id="+id

function CatTreeDragHandler(idFrom,idTo){
	//if we return false then drag&drop be aborted
//	alert(idFrom);
//	alert(idTo);
	return true;

function dpCatMoveError(node){
//	alert(node.getAttribute("type"));    // my_error
	alert(;    // Details
	return true;

function dpMove(node){
	alert(;    // Details
	return true;

function dpUpdate(nodeId, cType, newId) {
//    alert("Item was " + cType + "ed.");
	if (cType=="CatMoved"){
		return true;
		return false;

tree = new dhtmlXTreeObject("treeboxbox_tree", "100%", "100%", 0);

myDataProcessor = new dataProcessor("movecat.asp");
myDataProcessor.attachEvent("onAfterUpdate", dpUpdate);




you may use custom server-side response. Please have a look at the article: … _responses

Thank you, but I know that part and as you can see from the code I posted, I am receiving those custom error messages back to the javascript.

What I don’t know how to do is tell TREE NOT to complete the move of the category or to put it back if an error has occurred. All the Drag/Drop functions seem to fire BEFORE the data connector fires so none of them can be used to return FALSE.

If the item is already dropped, you need to delete it and insert it in the previous place. Or you may call moveItem method.