How to generate tree view in asp

Reply

Join Date: Jul 2007
Posts: 29
Reputation: creativehacker is an unknown quantity at this point 
Solved Threads: 0
creativehacker creativehacker is offline Offline
Light Poster

How to generate tree view in asp

 
0
  #1
Dec 26th, 2008
I want to generate a tree view using asp in which when I click the file (not the folder) the file should be deleted

I found this on net but how can I modify to delete a file when clicked on it.

http://classicasp.aspfaq.com/general...-from-asp.html

http://www.aspwebsolution.com/articl.../asp/index.htm
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 12
Reputation: closetosane is an unknown quantity at this point 
Solved Threads: 1
closetosane closetosane is offline Offline
Newbie Poster

Re: How to generate tree view in asp

 
0
  #2
Jan 5th, 2009
Here is a link for a very simple tree view: http://www.htmlforums.com/html-xhtml...ist-43732.html

It can be modified to allow for multiple tree views as shown in this example.

  1. <script type="text/javascript">
  2. function toggleBox(id){
  3. if (document.getElementById(id).style.display = = "") {
  4. show = "none";
  5. } else {
  6. show = "";
  7. }
  8. document.getElementById(id).style.display = show;
  9. }
  10. </script>
  11. </head>
  12. <body>
  13. <table width="100%" align="center">
  14. <tr>
  15. <td><a href="javascript:toggleBox(1)">+</a>&nbsp;<a href="" >Drive Letter</a></td>
  16. </tr>
  17. </table>
  18. <table width="100%" border="0" align="center" id="1" style="display: none;">
  19. <tr>
  20. <td bgcolor="#FFFFFF" width="30">&nbsp;</td>
  21. <td bgcolor="#FFFFFF" width="*">
  22. &nbsp;<a href="javascript:toggleBox(2)">+</a>&nbsp;<a href="" >Folder</a></td>
  23. </tr>
  24. </table>
  25. <table width="100%" border="0" align="center" id="2" style="display: none;">
  26. <tr>
  27. <td bgcolor="#FFFFFF" width="70">&nbsp;</td>
  28. <td bgcolor="#FFFFFF" width="*">&nbsp;
  29. <a href="../drive.asp?operator=Delete&file=C:\folder\filename.txt">File</a></td>
  30. </tr>
  31. </table>
  32. </body>
  33. </html>

So now with an easy to use tree the next thing you might want to do is use images instead or with the names in the tree as follows:

  1. %><td width="10"><a href="javascript:toggleBox(<%= intCount1 %>)">
  2. <img border="0" src="../Graphics/Folder.gif"></a><a href="" ></a></td><%

Also note that a variable “intCount1” is used instead of hard coding the javascript:toggleBox value, a variable can also be used with the ID to make this code very dynamic with some loops.

Now for the deleting file: A static tree makes no sense as you will need to change the code each time a file is deleted. For a dynamic list you will need to search the drive and write the file names into variables in the anchors. Start your tree with the root C:\ (or whatever your root/folder that you want to start is) Then search for folder names and files inside the folders as you loop through this write the values into the anchors. Example:
  1. <a href="../drive.asp?operator=Delete&file=<%= Path1 %>
  2.  
Path1 will be the path to the file example: (C:\folder\filename.txt).

So now that the tree is created when you click on the text or graphic corresponding to the path you will be directed to the html link with a querystring containing two values. The first value (in this case operator) will give a conditional statement, the second (File) will point to the path of the file you wish to delete.

  1. If operator = Delete Then
  2. Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
  3. objFSO.DeleteFile("C:\folder\filename.txt")
  4. End if
With C:\folder\filename.txt being the value contained in Path1

My assumption being that you are asking about asp pages is that you will be using vbscript and are on a windows server.

For some more information on FileSystemObjects check out the following links
http://www.microsoft.com/technet/scr...nda/files.mspx

http://www.activexperts.com/activmon...sfolders/files
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP Forum


Views: 1316 | Replies: 1
Thread Tools Search this Thread



Tag cloud for ASP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC