Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads
 
Add your own
alternative version
Go to top

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.
ajax_treeview_src.zip
ajax_treeview_src
ajax_treeview_src11
Global.asax
img
folder_closed.gif
folder_open.gif
minus.gif
plus.gif
transparent.gif
ajax_treeview_src20
App_Code
App_Data
img
folder_closed.gif
folder_open.gif
minus.gif
plus.gif
transparent.gif
ajax_treeview_src11.zip
img
folder_closed.gif
folder_open.gif
minus.gif
plus.gif
Thumbs.db
transparent.gif
Global.asax
// Copyright (c)2005 Rewritten Software.  http://www.rewrittensoftware.com
// 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.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace WebApplication1
{
	/// <summary>
	/// Test Page
	/// </summary>
	public class TreeTest : System.Web.UI.Page
	{
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			TreeView TreeView1 = (TreeView)this.FindControl("TreeView1");
			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)
				return;

			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);
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}

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.

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

Share

About the Author

Adrian Holland
Architect Webefinity
Australia Australia
Adrian is current the Solution Architect at CubeBuild.com.
 
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.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 26 Aug 2005
Article Copyright 2005 by Adrian Holland
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid