Solved

Do someone know Ajax treeview control that does not require to register component on server?

Posted on 2006-11-27
4
210 Views
Last Modified: 2007-03-20
Hi, we need Ajax treeview that does not require to registering component on server that can get server's files and folder?

Regards.
0
Comment
Question by:Abdu_Allah
  • 3
4 Comments
 
LVL 25

Expert Comment

by:kevp75
ID: 18024698
you should be able to do this with a little javascript and some ASP code.  I mention this route, only because you would need to make sure that latest XML component is installed on the server if vying for a AJAX route.

If you decide to do the AJAX route, remember you will need at least 2 files to do it....while, a simple recursive directory function, and a show/hide script would do what you need...

Let me know, I'll throw together something in the mean while...
0
 
LVL 25

Expert Comment

by:kevp75
ID: 18024851
have a look here:
http://www.portalfanatic.com/temp/test7.asp

gimme a minute or 20 and I'll have that treeview
0
 
LVL 25

Accepted Solution

by:
kevp75 earned 500 total points
ID: 18025228
ok.....have a look at the test page...

http://www.portalfanatic.com/temp/test7.asp

here's the code:

<%Server.ScriptTimeout=90000%>
<script type="text/javascript">
window.onload = function gmpinit(){
      if (document.getElementById){
            if (document.images){
                  icons = new Image();
                  icons.src = "";
            }
            var eLink = document.createElement("link");
            eLink.rel = "stylesheet";
            eLink.type = "text/css";
            eLink.media = "all";
            eLink.href= "/style.css";
            document.body.appendChild(eLink);
            ULnodes = document.getElementById("treenav").getElementsByTagName("UL");
            len = ULnodes.length;
            for(var i = 1; i < len; i++){
                  var folder = ULnodes[i].parentNode.firstChild;
                  folder.onclick = gmptc;
                  folder.className = "fc";
            }
}      }
function gmptc(){
      var target = this.nextSibling.nextSibling.style;
      target.display = target.display=="block"?"none":"block";
      this.className = this.className == "fc"?"fo":"fc";
}
expand = false;
function gmpec(){
      for(var i = 1; i < len; i++){
            ULnodes[i].parentNode.firstChild.className = expand==false?"fo":"fc";
            ULnodes[i].style.display = expand==false?"block":"none";
      }
      expand = expand==false?true:false;
}
</script>
<div id="treenav">
<p><a class="command" href="#" onclick="gmpec('e')">Expand All</a>/<a class="command" href="#" onclick="gmpec('c')">Collapse All</a></p>
<ul id="treenav_root">
<% ListFolderContents(server.mappath("/temp/temp3/")) %>
</ul>
<% sub ListFolderContents(path)
     dim fs, folder, file, item, url
     set fs = CreateObject("Scripting.FileSystemObject")
     set folder = fs.GetFolder(path)
    'Display the target folder and info.
     Response.Write("<li><a href=""#""><b>" & folder.Name & "</b></a> - " _
       & folder.Files.Count & " files, ")
     if folder.SubFolders.Count > 0 then
       Response.Write(folder.SubFolders.Count & " directories, ")
     end if
     'Response.Write(Round(folder.Size / 1024) & " KB total." _
       '& vbCrLf)
     Response.Write("<ul>" & vbCrLf)
     'Display a list of sub folders.
     for each item in folder.SubFolders
       ListFolderContents(item.Path)
     next
     'Display a list of files.
     for each item in folder.Files
       url = MapURL(item.path)
       Response.Write("<li><a href=/music/""" & url & """>" & item.Name & "</a> - " & item.Size & " bytes, " & "last modified on " & item.DateLastModified & "." _
         & "</li>" & vbCrLf)
     next
     Response.Write("</ul>" & vbCrLf)
     Response.Write("</li>" & vbCrLf)
   end sub
      function MapURL(path)
     dim rootPath, url
     'Convert a physical file path to a URL for hypertext links.
     rootPath = Server.MapPath("/music/")
     url = Right(path, Len(path) - Len(rootPath))
     MapURL = Replace(url, "\", "/")
   end function
%>
   </div>


I am having a spot of trouble with getting the tree to be closed by default...any takers???
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 18026498
I am not asking about how we do it!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now