tags:

views:

101

answers:

1

okay, so i have an asp.net (C#) application and i want to add a list of file and folders on the page, so i figured i should use JQuery fileTree (http://abeautifulsite.net/2008/03/jquery-file-tree/#download)

but now i am totally unable to display the file list.

I initialise the page this way:

Site.Master:

<link rel="stylesheet" type="text/css" href="../../Content/superfish.css" media="screen">
<link href="../../Content/jqueryFileTree.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.easing.1.3.js" type="text/javascript"></script>
<script src="../../Scripts/jqueryFileTree.js" type="text/javascript"></script>
<script src="../../Scripts/JqueryUI/js/jquery-ui-1.8.1.custom.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../../Scripts/jquery.dataTables.js"></script>
<script type="text/javascript" src="../../Scripts/superfish.js"></script>

    <script type="text/javascript">

        $(document).ready(function() {
        test = $('#fileTree').fileTree({script: "jqueryFileTree.aspx" }, function(file) {
            openFile(file);
            });

            $("button").button();

            oTable = $('#data').dataTable({
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "bSort": true
            });


        });
     </script>

and in the page, i put my div this way:

<div id="fileTree">

but i'm positive that jqueryFileTree.aspx is never "called" because if i return this page in my controller, it shows the list of files/folder correctly, so it's also not a problem with my aspx connector...

Also i checked, on the JS console, it gives no error and there is nothing more in the page source code

i've been trying to solve this all day without success so your help is apreciated

Edit: formatting problems As Requested, Posting jQueryFileTree.aspx:

string dir;
if(Request.Form["dir"] == null || Request.Form["dir"].Length <= 0)
    dir = "/";
else
    dir = Server.UrlDecode(Request.Form["dir"]);
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(dir);
Response.Write("<ul class=\"jqueryFileTree\" style=\"display: none;\">\n");
foreach (System.IO.DirectoryInfo di_child in di.GetDirectories())
    Response.Write("\t<li class=\"directory collapsed\"><a href=\"#\" rel=\"" + dir + di_child.Name + "/\">" + di_child.Name + "</a></li>\n");
foreach (System.IO.FileInfo fi in di.GetFiles())
{
    string ext = ""; 
    if(fi.Extension.Length > 1)
        ext = fi.Extension.Substring(1).ToLower();

    Response.Write("\t<li class=\"file ext_" + ext + "\"><a href=\"#\" rel=\"" + dir + fi.Name + "\">" + fi.Name + "</a></li>\n");      
}
Response.Write("</ul>");
+1  A: 

This may be completely unrelated, but make sure you close your very first link tag with a /> at the end.

<link rel="stylesheet" type="text/css" href="../../Content/superfish.css" media="screen" />

Are you sure your javascript is getting called? Try putting an alert("<sample debug message here>") or two in your document.ready function and see if anything is getting called at all.

Nate Dudek
Yeah i did notice the missing '/' after posting, corrected it. i tried adding an "alert" in the js file and it's displayed...plus i'm trying to debug with Chrome but i don,t know much about JS :(
Gadgetsan
I think you need to add a "root" parameter in your filetree() call. This parameter is relative to your hard drive, not to your asp.net app. For example, if you wanted to display a tree of C:\windows, you would specify root: '/windows/:fileTree({ script: "jqueryFileTree.aspx", root: "/windows/"});It also may help if you post your jqueryFileTree.aspx code.
Nate Dudek
i know for a fact that by default, it will use "/" as the root directory and that probably isn't the issue... i did try it anyway without any success
Gadgetsan
Taking a look at your aspx file now... I'm going to set everything up locally and debug.
Nate Dudek
thank you, that's really nice of you!
Gadgetsan
It works for me with a sample local project, BUT:1) I was able to recreate your problem when my "<script src" paths were wrong. In my particular project, I had to change "../../Scripts/" to "Scripts/" So, make absolutely sure your paths are correct or it may not function.2) Try remove your extra javascript... the button() call and your datatables call. If something goes wrong with those, it could cause all of your javascript to not function.3) I would also change your openFile() to an alert() until you get it working. Eliminate all possibly variables.
Nate Dudek
you are my savior! okay so, as you said, i removed the "../.." and i also changed the script: 'jqueryFileTree.aspx' to script: 'Scripts/jqueryFileTree.aspx' i then moved the .aspx to the "Scripts" directory to make it work:D thanks a lot!
Gadgetsan
Great!! Glad you got it working.
Nate Dudek