Click here to Skip to main content
15,887,485 members
Articles / Web Development / IIS
Article

A Tree Control using ASP

Rate me:
Please Sign up or sign in to vote.
2.78/5 (8 votes)
15 May 2000 288.2K   4K   35   45
A simple tree control written using ASP that allows you to display hierachical data.
  • Download source files - 16 Kb
  • Sample Image - TreeControl.jpg

    The project is a simple Tree Control created using ASP. This is first version that offers only display feature, but in the next version the user will be able to add, edit and delete nodes.

    The Tree Control structure is stored in an access database. The TreeContent table has following columns:

  • IDNode – number, is the node ID and it not be duplicated.
  • IDParentNode – number, is the ID parent node.
  • NodeCaption – string, node caption that will be displayed in the page.
  • NodeType – string, is type of node. Can be one from two valid values: F – folder, I – item. If it contains another value then the node will be folder (F).
  • NodeAction – string, is node action. Is available only for items node, if the node is folder then it has only one action – expand tree. i.e. for node action: http://www.microsoft.com, javascript:alert("Test"), mailto:iulian_iuga@yahoo.com.
  • The Tree Control can be expanded only to one branch. So, you must modify the path for the database or create a DNS for database connection in the TreeWork.asp file:

    // ' Here YOU MUST change the database path, or create a DSN
    // Const cstrConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=D:\Iulian\TestTree\testtree.mdb"
    

    Thanks again and enjoy ...

    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


    Written By
    Web Developer
    Germany Germany
    This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

    Comments and Discussions

     
    GeneralMulti-Column TreeView Pin
    Jim Brooks3-Nov-07 10:47
    Jim Brooks3-Nov-07 10:47 
    Generalreply immediately my mail Pin
    lingeswararaj.s3-Dec-06 22:46
    lingeswararaj.s3-Dec-06 22:46 
    GeneralA Tree Control using ASP Pin
    odiebaby15-Mar-06 19:33
    odiebaby15-Mar-06 19:33 
    GeneralPretty good! Pin
    deepakjha13-Jan-05 1:48
    deepakjha13-Jan-05 1:48 
    GeneralRe: Pretty good! Pin
    anu_dreams9-Jun-05 3:48
    anu_dreams9-Jun-05 3:48 
    GeneralRe: Pretty good! Pin
    vickyvinod117-Dec-09 20:10
    vickyvinod117-Dec-09 20:10 
    GeneralError Message Pin
    acpt15-Dec-04 18:41
    acpt15-Dec-04 18:41 
    GeneralRe: Error Message Pin
    Iulian Iuga7-Jan-05 1:13
    Iulian Iuga7-Jan-05 1:13 
    GeneralRe: Error Message Pin
    anu_dreams9-Jun-05 3:50
    anu_dreams9-Jun-05 3:50 
    GeneralRe: Error Message Pin
    Member 889484930-Apr-12 1:39
    Member 889484930-Apr-12 1:39 
    QuestionHow to create a tree with infinite no of child Pin
    percyvimal17-Mar-04 23:30
    percyvimal17-Mar-04 23:30 
    Generalcode does not work Pin
    Member 79217429-Dec-03 23:22
    Member 79217429-Dec-03 23:22 
    GeneralExcellent control Pin
    AveryH13-Nov-03 22:54
    AveryH13-Nov-03 22:54 
    GeneralError, general error. Watch the code! (1.5) Pin
    Iulian Iuga3-Nov-03 7:42
    Iulian Iuga3-Nov-03 7:42 
    GeneralRe: Error, general error. Watch the code! (1.5) Pin
    percyvimal11-Mar-04 16:56
    percyvimal11-Mar-04 16:56 
    Generalyour code is not work Pin
    Populate12323-Sep-03 1:07
    Populate12323-Sep-03 1:07 
    Hi Iulian,

    I try to run your code, but this not work. I am asp developer(also do others like php). I Changed ur code pls chk this. but it does not show any error or not go to if not rs.eof or else part.

    --------------------code----------------

    sub ReadTreeContent(p_strConnectionString, _
    p_strQuery)

    'On Error Resume Next

    dim objConn
    dim objRS

    set objConn = server.CreateObject("ADODB.Connection")
    if Err.number <> 0 then
    'RedirectToError ERR_CANNOT_CREATE_CONNECTION_OBJECT & "(1.1)", false
    Response.Write err.Description&err.number
    end if

    objConn.Open p_strConnectionString
    if Err.number <> 0 then
    'RedirectToError ERR_CANNOT_OPEN_DATABASE & "(1.2)", false
    Response.Write "
    open error "&err.Description&" "&err.number
    end if

    set objRS = objConn.Execute(p_strQuery,,adCmdText)
    if Err.number <> 0 then
    'RedirectToError ERR_CANNOT_EXECUTE_QUERY & "(1.3)", false
    Response.Write "
    Recordset error "&err.Description&" "&err.number
    end if

    if not objRS.EOF then
    Response.Write "Enter"
    StoreTreeContent objRS
    else
    Response.Write "End Of file"
    end if

    set objRS = nothing
    set objConn = nothing
    end sub

    ---------------end code----------------

    Is there any new version? pls mail me at himadrish@yahoo.com
    Regards,
    HIMADRISHSmile | :)

    Himadrish Laha
    GeneralError, general error. Pin
    chungwong16-Jun-03 9:43
    chungwong16-Jun-03 9:43 
    GeneralRe: Error, general error. Pin
    Iulian Iuga16-Jun-03 20:37
    Iulian Iuga16-Jun-03 20:37 
    GeneralTree should remain always expanded Pin
    Member 42957228-May-03 23:12
    Member 42957228-May-03 23:12 
    GeneralError Page Pin
    Anonymous18-Dec-02 18:48
    Anonymous18-Dec-02 18:48 
    GeneralRe: Error Page Pin
    Iulian Iuga18-Dec-02 21:43
    Iulian Iuga18-Dec-02 21:43 
    GeneralRe: Error Page Pin
    shekhar_shah200030-Jan-03 6:15
    shekhar_shah200030-Jan-03 6:15 
    Generaliam also getting the same error 1.5 please help Pin
    rahil18-Aug-03 9:42
    rahil18-Aug-03 9:42 
    GeneralRe: iam also getting the same error 1.5 please help Pin
    Iulian Iuga1-Sep-03 1:45
    Iulian Iuga1-Sep-03 1:45 
    Generaliam also getting the same error 1.5 please help Pin
    emmanuelconstant22-Oct-03 6:15
    emmanuelconstant22-Oct-03 6:15 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.