On the client-side we added a number of parameters for each event we want to handle.
We also specified in the post function the name of the server-side method which will implement
the server-side processing for each event.
The arguments of these methods will be the parameters created with the AddParam function.
For adding nodes:
public string OnAddNode(string parentId, string childId, string textOrHTML, string expanded,
string image, string subTreeURL)
{
oTreeDB.Fields[TreeDB.StandardFields.ParentID].Value = parentId;
oTreeDB.Fields[TreeDB.StandardFields.ID].Value = childId;
oTreeDB.Fields[TreeDB.StandardFields.HTMLValue].Value = textOrHTML;
oTreeDB.Fields[TreeDB.StandardFields.Expanded].Value = expanded;
oTreeDB.Fields[TreeDB.StandardFields.Icon].Value = image;
// process the information and returning the result:
string sResult = oTreeDB.ExecuteEvent(TreeDB.EventTypes.Add);
if (sResult != "1") { throw new Exception(sResult); }
return sResult;
}
For editing nodes:
public string OnNodeEdit(string id, string text, string prevText)
{
// specify the type of action that the Tree_DB component should take:
oTreeDB.EventType = TreeDB.EventTypes.Edit;
// prepare tha data for the Tree_DB object
oTreeDB.Fields[TreeDB.StandardFields.ID].Value = id;
oTreeDB.Fields[TreeDB.StandardFields.HTMLValue].Value = text;
// process the information and returning the result:
string sResult = oTreeDB.ExecuteEvent();
if (sResult != "1") { throw new Exception(sResult); }
return sResult;
}
For removing nodes:
public string OnRemoveNode(string id)
{
// specify the type of action that the Tree_DB component should take:
oTreeDB.EventType = TreeDB.EventTypes.Remove;
// prepare tha data for the Tree_DB object - the data should be sent using this format:
oTreeDB.Fields[TreeDB.StandardFields.ID].Value = id;
// process the information and returning the result:
string sResult = oTreeDB.ExecuteEvent();
if (sResult != "1") { throw new Exception(sResult); }
return sResult;
}
For updating the level of the nodes:
public string OnNodeDrop(string src, string dst)
{
// specify the type of action that the Tree_DB component should take:
oTreeDB.EventType = TreeDB.EventTypes.UpdateLevel;
// prepare tha data for the Tree_DB object - the data should be sent using this format:
oTreeDB.Fields[TreeDB.StandardFields.ID].Value = src;
oTreeDB.Fields[TreeDB.StandardFields.ParentID].Value = dst;
// process the information and returning the result:
string sResult = oTreeDB.ExecuteEvent();
if (sResult != "1") { throw new Exception(sResult); }
return sResult;
}
Read more about implementing the server-side methods for the AJAX Page control.
For any questions send us a support request. See How-To and Help page
|