ASP Code
  Home arrow ASP Code arrow Remote Scripting to dynamically add the le...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP CODE

Remote Scripting to dynamically add the leaves to a Tree Control
By: Adrian Forbes
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2003-01-01

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


     

     

    This Demo uses remote scripting to dynamically add the leaves. i.e. it loads the root items first then loads the child items when you expand the parent item.  Note:that with the remote scripting samples there is a hard-coded path to the relevant support files, this will have to be changed appropriately for people to get the demos to work on their own system. 

    First Page--RSTreeView.htm

    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE>TreeView using Remote Scripting</TITLE>
    </HEAD>
    <BODY>
    <!-- Author: Adrian Forbes -->
    <script language="JavaScript" src="../_scriptlibrary/rs.htm"></script>
    <script language="JavaScript">RSEnableRemoteScripting("../_scriptlibrary");</script>

    <OBJECT ID="tvwTree" WIDTH=300 HEIGHT=276
    CLASSID="CLSID:0713E8A2-850A-101B-AFC0-4210102A8DA7">
    <PARAM NAME="_ExtentX" VALUE="7938">
    <PARAM NAME="_ExtentY" VALUE="7303">
    <PARAM NAME="_Version" VALUE="327682">
    <PARAM NAME="Indentation" VALUE="0">
    <PARAM NAME="LabelEdit" VALUE="1">
    <PARAM NAME="LineStyle" VALUE="1">
    <PARAM NAME="Style" VALUE="7">
    <PARAM NAME="Appearance" VALUE="1">
    </OBJECT>
    <p>
    <input type=BUTTON onClick="SubmitNode();" value="Select" id=BUTTON1 name=BUTTON1>
    </p>
    <form name=frmTree action="TreeControlTarget.asp" method=GET>
    <input type=HIDDEN name=txtSelected>
    </form>

    <script language=VBScript>
    strDBPage = "RSDatabase.asp"
    tvwChild = 4

    sub window_onLoad
        LoadParents
    end sub

    function LoadParents

        set objRS = RSExecute(strDBPage ,"GetDBParents")
        sRS = objRS.return_value
        aRows = Split(sRS, Chr(13))

        tvwTree.Nodes.Clear
       
        for i = 0 to UBound(aRows) - 1
            aFields = Split(aRows(i), ";")
            Set tmpNode = tvwTree.Nodes.Add(, , "P" & aFields(0), aFields(1))
            tvwTree.Nodes.Add tmpNode, tvwChild, , "DUMMY"
        next

    end function

    Sub tvwTree_Expand(ByVal Node)
    dim tmpRS, lHeaderID
    dim sOld, sNew

        If Node.Child.Text <> "DUMMY" Then
            exit sub
        end if

        tvwTree.Nodes.Remove Node.Child.Index

        lID = mid(node.Key, 2)
        set objRS = RSExecute(strDBPage ,"GetDBChildren", lID)
        sRS = objRS.return_value
        aRows = Split(sRS, Chr(13))

        for i = 0 to UBound(aRows) - 1
            aFields = Split(aRows(i), ";")
            tvwTree.Nodes.Add Node, tvwChild, "C" & aFields(0), aFields(1)
        next

    End Sub

    sub SubmitNode
        if document.tvwTree.selecteditem is nothing then
            msgbox "Select an item from the tree"
        else
            document.frmTree.txtSelected.value = document.tvwTree.selecteditem.text
            document.frmTree.submit
        end if
    end sub
    </script>

    </BODY>
    </HTML>

    Page 2 RSDatabase.asp

    <%@ LANGUAGE=VBSCRIPT %>
    <%
    strconn = "Driver={SQL Server};Description=sqldemo;SERVER=127.0.0.1;UID=LoginID;PWD=Password;DATABASE=Database_Name
    %>
    <% RSDispatch %>
    <!-- Author: Adrian Forbes -->
    <!--#INCLUDE FILE="../_ScriptLibrary/rs.asp"-->
    <SCRIPT RUNAT=SERVER Language=javascript>
        function Description()
        {
            this.GetDBParents = Function( 'return GetDBParents()' );
            this.GetDBChildren = Function('ID', 'return GetDBChildren(ID)' );
            this.Method1 = Method1;
        }
        public_description = new Description();

    function Method1()
    {
        return 'Test';
    }
    </script>

    <SCRIPT RUNAT=SERVER Language=VBScript>
        function GetDBParents()

            set objRS = createobject("ADODB.Recordset")
            objRS.Open "select ID, strParent from Parents", strconn
            GetDBParents = objRS.GetString(, , ";")
            objRS.Close
            set objRS.ActiveConnection = nothing
            set objRS = nothing
           
        end function

        function GetDBChildren(ID)

            set objRS = createobject("ADODB.Recordset")
            objRS.Open "select ID, strChild from Children WHERE intParent=" & ID, strconn
            GetDBChildren = objRS.GetString(, , ";")
            objRS.Close
            set objRS.ActiveConnection = nothing
            set objRS = nothing
           
        end function
    </SCRIPT>





    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More ASP Code Articles
    More By Adrian Forbes

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Best Practices: The Integrated Project and Portfolio Management Platform.

    Hear how IBM Rational Project and Portfolio Management integrated solutions help teams put the right tools and processes in place to maximize the effectiveness and efficiency of project teams and ensure that the business vision is being executed correctly. Learn how to automate and integrate requirements prioritization, top-down project planning, communications and controls, and methodology deployment to keep your scope, costs, and schedules under control. Tackle with an end-to-end approach the management of scope and scope changes, usage of methodology to control and empower project teams, and optimization of resources to align activity costs with the overall project plan.
    FREE! Go There Now!


    NEW! Applying lean thinking to the governance of software development

    Effective governance for lean development isn’t about command and control. Instead, the focus is on enabling the right behaviors and practices through collaborative and supportive techniques. Hear from Scott Ambler on how it is far more effective to motivate people to do the right thing than it is to force them to do so. Learn how to form a lightweight, collaboration-based framework that reflects the realities of modern IT organizations.
    FREE! Go There Now!


    NEW! Best Practices in Integrated Requirements Management

    Poor Requirements Management capabilities in an Enterprise have been linked to excessive project failures, escalating IT costs, and failure to deliver competitive advantage into the marketplace. Join Brianna M Smith from IBM Rational and learn about how successful organizations align IT and Business stakeholders through collaborative processes and tools for effective requirements management, and how an integrated approach across the IT lifecycle can provide unparalleled visibility and traceability to ensure that project teams are delivering on the business vision by "doing the right things" and "doing things right."
    FREE! Go There Now!


    NEW! Download the free Web Application Security eKit

    Discover how IBM Rational AppScan Standard Edition can help you detext vulnerabilities in your web applications in the Web Application Security eKit. IBM Rational AppScan is a leading suite of automated web application security solutions that scan and test for common Web application vulnerabilities. The new Web Application Security eKit provides you with valuable resources, including white papers, demos, and additional information on the benefits of testing your Web applications.
    FREE! Go There Now!


    NEW! Improve your build process with IBM Rational Build Forge, Part 2: Automate builds for a real-world Tomcat project

    Learn how Rational Build Forge can extend a simple compile and package build process by adding customization and deployment capability. Go from a manual method to automating: checking for code changes; getting the latest source; compiling and packaging; customizing; copying to and restarting a deployment server; and sending e-mail notification that a new version is available.
    FREE! Go There Now!


    NEW! Rational Build Forge Express eKit

    Rational Build Forge Express Edition is an automation framework that packages the latest enterprise-grade technologies into a reliable, flexible and robust configuration designed and priced specifically for small to midsize businesses. The new Rational Build Forge Express eKit provides you with valuable resources – including a case study, podcast, demo, and articles – to help you increase staff productivity, compress development cycles and deliver better software, fast.
    FREE! Go There Now!


    NEW! The dirty dozen: preventing common application-level hack attacks

    As organizations have grown increasingly dependent on online software, the risk of malicious attacks has also become far more serious. Fortunately, well-governed organizations can protect their Web applications by injecting vulnerability assessments and ethical hacks into their software development and delivery processes. This paper describes 12 of the most common hacker attacks and provides basic rules that you can follow to help create more hack-resistant Web applications.
    FREE! Go There Now!


    NEW! Trial download: IBM Lotus Forms V3.0

    Get a free trial download of IBM Lotus Forms V3.0 (formerly Workplace Forms), which provides a zero-footprint eForms solution to help you automate and move forms-based business processes off the desktop and onto the Web. With Lotus Forms, you can extend applications beyond the firewall by creating a single electronic form document ready for use in both thick and Web 2.0 thin client format.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Method Composer V7.2

    Get a free trial download of the latest version of IBM Rational Method Composer V7.2 which helps you deliver customized yet consistent process guidance to your project teams and IT organization, and includes the latest version of IBM Rational Unified Process (RUP), which has provided process guidance to teams since 1996.
    FREE! Go There Now!


    NEW! Whitepaper: Achieving consistency between business process models and operational guides

    Explore how Rational and WebSphere software enable enterprise documentation in SOA environments. Specifically, a new integration between IBM WebSphere® Business Modeler and IBM Rational® Method Composer software can help technical writers more easily keep enterprise operations manuals in sync with changes that are made to business processes, resulting in more accurate and timely documentation that benefits the entire enterprise.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP CODE ARTICLES

    - ASP Forms
    - ASP: The Beginning
    - Getting Remote Files With ASP Continued
    - Inbox and Outbox Manipulation in ASP
    - Relational DropDownList Using VB.NET
    - Ad Tracking URL Hits
    - Use ViewState to display one record per page...
    - Send Email using ASP.NET formatted in HTML
    - ASP File Explorer
    - ASP/XML Interview questions by Srivatsan Sri...
    - Various methods of setting Date values to a ...
    - Conditional DataGrid Item and using checkbox...
    - Fill .NET Listbox with SQL DataReader
    - Filling Dropdown box using Code-Behinds in C#
    - FLAMES code sample written in .NET What is F...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek