hi, in the code behind I call a Confirm box in javascript(client-side), with a button that says Yes an other that says No. If the user clicks NO, the method CancelNodeEdited() is called. So I pass the old description as the argument. The problem is that if the user edit the node and enter a new description, then the Confirm box is showed. If the user clicks No, the new description is showed and the old description is not taken. How can I fix this problem ?
if ((dtProjects.Rows.Count > 0) && (checkClientAdminRole()))
{
// set old value to cancel action
e.Node.Attributes["OldNodeDescription"] = e.Node.Attributes["NodeDescription"];
// create warning message
sMessage = "Are you sure you want to edit the Taxanomy? The Tax Return Line is used within your Client by:\\n" + sOtherProjectName;
sMessage = sMessage.Replace("\\", "\\\\").Replace("'", "\\'").Replace("\"", "\\\"");
// register script for user confirmation
sScript = @"var resultado = confirm('" + sMessage + "'); if (!resultado) CancelNodeEdited('" + e.Node.Attributes["OldNodeDescription"] + "');";
ClientScript.RegisterStartupScript(typeof(Page), "jsEditNode", sScript, true);
// set new value
e.Node.Text = e.Node.Attributes["TaxonomyNotation"] + " " + nodeText;
and in the aspx;
function CancelNodeEdited(oldValue) {
tree = document.getElementById('<%=trTaxonomy.ClientID%>');
var node = tree.FindNodeByAttribute("NodeDescription", oldValue);
nodetext = node.get_attributes().getAttribute("OldNodeDescription");
node.get_attributes().setAttribute("NodeDescription", nodetext);
node.set_text(node.get_attributes().getAttribute("TaxonomyNotation") + " " + nodetext);
node.get_attributes().setAttribute("OldNodeDescription", null);
}
if ((dtProjects.Rows.Count > 0) && (checkClientAdminRole()))
{
// set old value to cancel action
e.Node.Attributes["OldNodeDescription"] = e.Node.Attributes["NodeDescription"];
// create warning message
sMessage = "Are you sure you want to edit the Taxanomy? The Tax Return Line is used within your Client by:\\n" + sOtherProjectName;
sMessage = sMessage.Replace("\\", "\\\\").Replace("'", "\\'").Replace("\"", "\\\"");
// register script for user confirmation
sScript = @"var resultado = confirm('" + sMessage + "'); if (!resultado) CancelNodeEdited('" + e.Node.Attributes["OldNodeDescription"] + "');";
ClientScript.RegisterStartupScript(typeof(Page), "jsEditNode", sScript, true);
// set new value
e.Node.Text = e.Node.Attributes["TaxonomyNotation"] + " " + nodeText;
and in the aspx;
function CancelNodeEdited(oldValue) {
tree = document.getElementById('<%=trTaxonomy.ClientID%>');
var node = tree.FindNodeByAttribute("NodeDescription", oldValue);
nodetext = node.get_attributes().getAttribute("OldNodeDescription");
node.get_attributes().setAttribute("NodeDescription", nodetext);
node.set_text(node.get_attributes().getAttribute("TaxonomyNotation") + " " + nodetext);
node.get_attributes().setAttribute("OldNodeDescription", null);
}