live demo  |   download

Because of several requests about the slow load time of my former treeview control (when table records exceed 2000) I have developed this simple ajax treeview solution to take advantage of its Load on Demand feature so that no mater how large a dataset is, the treeview will always load quickly.
This solution is aimed at those who want to dynamically load their treeview items from a database with many records.

Figure 1
Simple Ajax/ASP Treeview

The code for this treeview solution is quite different because instead of using <UL/> element, it uses the <TABLE/> element because some users wanted to be able to click the +/- signs to open/close the treeview and add a link to all tree nodes.

The source code for this solution cotains the following files:
  1. treeview.asp:The treeview source file which implements the public function GetChildNodes(intParentId) which returns a transformed XML string of the child nodes. Other private helper functions include: GetDbXml, GetDbString & LoadXmlDoc
  2. treeview.xsl - the stylesheet to transform the XML.
  3. site.mdb - the sample database
  4. ajax.js & scripts.js - contain the Ajax and javascript functions required to load the treenodes dynamically.
  5. process_request.asp - the file that is loaded by the Ajax function.
This code is not only great for ASP programmers, but also for developers who want to learn how easy it is to implement Ajax solutions to web applications. This code could easily be ported to .NET or PHP since the code functionality is the XSL stylesheet and the javascript functions.