private TreeNode CreateNode(string nodeText, string nodeValue, TreeNode parentNode, int childCount, int index)
    {
        TreeNode node = new TreeNode();

        if (!String.IsNullOrEmpty(CustomSelectFunction))
        {
            string output = "<span ";
            string val    = nodeValue;
            if (parentNode != null)
            {
                val = parentNode.ValuePath.ToLowerCSafe() + treeElem.PathSeparator + nodeValue.ToLowerCSafe();
            }
            node.SelectAction = TreeNodeSelectAction.None;
            if (index <= MaxSubFolders)
            {
                output += "onClick=\" document.getElementById('" + hdnPath.ClientID + "').value = '" + val.Replace("\\", "\\\\") + "'; ";
                if ((childCount > MaxSubFolders) && !String.IsNullOrEmpty(CustomClickForMoreFunction))
                {
                    output += CustomClickForMoreFunction.Replace("##NODEVALUE##", val.Replace('\\', '|')) + " return false;\" ";
                }
                else
                {
                    output += CustomSelectFunction.Replace("##NODEVALUE##", val.Replace('\\', '|')) + " return false;\" ";
                }
            }
            else if (!string.IsNullOrEmpty(CustomClickForMoreFunction) && (parentNode != null))
            {
                output += "onClick=\" document.getElementById('" + hdnPath.ClientID + "').value = '" + parentNode.ValuePath.Replace("\\", "\\\\") + "'; ";
                output += CustomClickForMoreFunction.Replace("##NODEVALUE##", parentNode.ValuePath.Replace('\\', '|')) + " return false;\" ";
            }

            output   += ">";
            output   += nodeText;
            output   += "</span>";
            node.Text = output;
        }
        else
        {
            node.Text = nodeText;
        }
        node.Value = nodeValue.ToLowerCSafe();

        return(node);
    }
示例#2
0
    /// <summary>
    /// Creates a HTML node used in the tree.
    /// </summary>
    /// <param name="nodeText">Text opf the node</param>
    /// <param name="nodeValue">Path of the node in the tree</param>
    /// <param name="parrentNode">Parent node element</param>
    /// <param name="childCount">Number of child elements (folders)</param>
    /// <param name="index">Index of the currently processed node</param>
    private TreeNode CreateNode(string nodeText, string nodeValue, TreeNode parrentNode, int childCount, int index)
    {
        TreeNode node = new TreeNode();

        if (!String.IsNullOrEmpty(CustomSelectFunction))
        {
            string output = "<span ";

            string val = nodeValue;
            if (parrentNode != null)
            {
                val = parrentNode.ValuePath + treeElem.PathSeparator + nodeValue;
            }

            // IDs
            string folderId = "";
            if (GenerateIDs)
            {
                folderId = EnsurePath(val);

                output += "id=\"" + folderId + "\" ";
            }

            node.SelectAction = TreeNodeSelectAction.None;
            if (ShowFolder(index))
            {
                output += "onClick=\" document.getElementById('" + hdnPath.ClientID + "').value = '" + folderId + "'; ";
                if (!ShowFolder(childCount) && !String.IsNullOrEmpty(CustomClickForMoreFunction))
                {
                    output += CustomClickForMoreFunction.Replace("##NODEVALUE##", val.Replace('\\', '|').Replace("\'", "\\\'")).Replace("##FOLDERID##", folderId).Replace("##TYPE##", "folder") + " return false;\" ";
                }
                else
                {
                    output += CustomSelectFunction.Replace("##NODEVALUE##", val.Replace('\\', '|').Replace("\'", "\\\'")).Replace("##FOLDERID##", folderId) + " return false;\" ";
                }
            }
            else if (!string.IsNullOrEmpty(CustomClickForMoreFunction))
            {
                string parentFolderId = "";
                if (GenerateIDs)
                {
                    parentFolderId = EnsurePath(parrentNode.ValuePath);
                }

                output += "onClick=\" document.getElementById('" + hdnPath.ClientID + "').value = '" + parentFolderId.Replace("\\", "\\\\").Replace("\'", "\\\'") + "'; ";
                output += CustomClickForMoreFunction.Replace("##NODEVALUE##", parrentNode.ValuePath.Replace('\\', '|').Replace("\'", "\\\'")).Replace("##FOLDERID##", parentFolderId).Replace("##TYPE##", "link") + " return false;\" ";
            }

            output   += ">";
            output   += nodeText;
            output   += "</span>";
            node.Text = output;
        }
        else
        {
            node.Text = nodeText;
        }
        node.Value = nodeValue;

        return(node);
    }