| | |
How to generate tree view in asp
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2007
Posts: 29
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Jan 2009
Posts: 12
Reputation:
Solved Threads: 1
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.
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:
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:
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.
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
It can be modified to allow for multiple tree views as shown in this example.
ASP Syntax (Toggle Plain Text)
<script type="text/javascript"> function toggleBox(id){ if (document.getElementById(id).style.display = = "") { show = "none"; } else { show = ""; } document.getElementById(id).style.display = show; } </script> </head> <body> <table width="100%" align="center"> <tr> <td><a href="javascript:toggleBox(1)">+</a> <a href="" >Drive Letter</a></td> </tr> </table> <table width="100%" border="0" align="center" id="1" style="display: none;"> <tr> <td bgcolor="#FFFFFF" width="30"> </td> <td bgcolor="#FFFFFF" width="*"> <a href="javascript:toggleBox(2)">+</a> <a href="" >Folder</a></td> </tr> </table> <table width="100%" border="0" align="center" id="2" style="display: none;"> <tr> <td bgcolor="#FFFFFF" width="70"> </td> <td bgcolor="#FFFFFF" width="*"> <a href="../drive.asp?operator=Delete&file=C:\folder\filename.txt">File</a></td> </tr> </table> </body> </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:
ASP Syntax (Toggle Plain Text)
%><td width="10"><a href="javascript:toggleBox(<%= intCount1 %>)"> <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:
ASP Syntax (Toggle Plain Text)
<a href="../drive.asp?operator=Delete&file=<%= Path1 %>
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.
ASP Syntax (Toggle Plain Text)
If operator = Delete Then Set objFSO = Server.CreateObject("Scripting.FileSystemObject") objFSO.DeleteFile("C:\folder\filename.txt") End if
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
![]() |
Similar Threads
- Winsock Multi-Client Servers (C++)
- Help with automatic update problem and more (Viruses, Spyware and other Nasties)
Other Threads in the ASP Forum
- Previous Thread: hi
- Next Thread: Session problem in asp
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection calendar changeable connection current database databaseconnection diagnostics dreamweaver excel fso html iis microsoft msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption server single specfic sqlserver sqlserverconnection toolkit web webserver windows7





