Introduction
ASP.NET tree control is a Custom Control (.ascx) that builds a tree structure. All you have to do is to use two methods of the control. The AddNodeDiv
which will add a Node and BuildTree
which will build it. Please note that the Node type parent should be only used for the first level nodes. The Node Click event is raised and the source code is in JavaScript file. The control also selects the current node. You can make this as a DLL by just copying the methods and properties to a class file
The following will explain how to use the control:
- Add the mrTree.ascx, mrtree.ascx.vb, mrFunctions.js, plus.gif, minus.gif files to your Visual Studio .NET project.
- Drag the mrTree.ascx to your aspx page (in design mode).
- Declare your tree (
Public mrTree1 As mrTree
)
- Use the
AddNodeDiv
method of the Tree to build your nodes (See examples).
- Once you have added all your Nodes, call the
BuildTree()
method to build the tree.
- If there are any errors in building, the control will write it to
Errors
property of the tree.
- The JavaScript file has the function which run when you click the node.
- You can always change the source code to fit your needs.
I hope this helps.