Solved

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

Posted on 2006-11-27
4
208 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

18 Experts available now in Live!

Get 1:1 Help Now