Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

ASP.NET Tree Control

0.00/5 (No votes)
12 Jun 2003 1  
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 the Node and BuildTree which will build it.

Sample Image - Preview.gif

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:

  1. Add the mrTree.ascx, mrtree.ascx.vb, mrFunctions.js, plus.gif, minus.gif files to your Visual Studio .NET project.
  2. Drag the mrTree.ascx to your aspx page (in design mode).
  3. Declare your tree (Public mrTree1 As mrTree)
  4. Use the AddNodeDiv method of the Tree to build your nodes (See examples).
  5. Once you have added all your Nodes, call the BuildTree() method to build the tree.
  6. If there are any errors in building, the control will write it to Errors property of the tree.
  7. The JavaScript file has the function which run when you click the node.
  8. You can always change the source code to fit your needs.

I hope this helps.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here