Click here to Skip to main content
13,357,171 members (72,096 online)
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads


84 bookmarked
Posted 25 Aug 2005

DHTML Tree View of Arbitrary Depth using AJAX

, 25 Aug 2005
This article provides a gentle introduction to AJAX by applying that technology to significantly enhance a tree previously rendered using JavaScript.
// Copyright (c)2005 Rewritten Software.
// This script is supplied "as is" without any form of warranty. Rewritten Software 
// shall not be liable for any loss or damage to person or property as a result of using this script.
// Use this script at your own risk!
// You are licensed to use this script free of charge for commercial or non-commercial use providing you do not remove 
// the copyright notice or disclaimer.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        Tree tree = new Tree("mytree");
        tree.Root = new TreeNode("Root", "", "img/folder_open.gif", "img/folder_closed.gif");
        BuildTree(0, tree.Root);
        TreeView1.DisplayTree = tree;

    protected void BuildTree(int depth, TreeNode node)
        if (depth > 4)

        for (int i=0; i<10; i++)
            node.Children.Add(new TreeNode("Node " + depth + i, "", "img/folder_open.gif", "img/folder_closed.gif"));

        foreach (TreeNode child in node.Children)
            BuildTree(depth + 1, child);

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


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


About the Author

Adrian Holland
Architect Webefinity
Australia Australia
Adrian is current the Solution Architect at

The core of CubeBuild is a website and application platform that is pluggable into ASP.NET MVC. Any MVC application can have content authoring added to its pages with little effort, and new content types are created using IronPython.NET open source components.

We are currently deploying a Point of Service (Web based POS) built on CubeBuild which allows a single web channel for face-to-face sales, and sales through your online store. All from a single inventory base, and from any device.

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 26 Aug 2005
Article Copyright 2005 by Adrian Holland
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid