treeview navigateurl

subNode.NavigateUrl = "WebDocuments/" & fi.Name.ToString() <<<<I can click on the items in the top folder called webdocumnets, but any items in subfolders will not pull up.  I understand that the url it is looking for is wrong, I'm just not sure how to get the subfolders in the url.
Dim directory As DirectoryInfo = Nothing
        directory = New DirectoryInfo(node.Value)

        For Each subtree As DirectoryInfo In directory.GetDirectories()
            Dim subNode As New TreeNode(subtree.Name)
            subNode.Value = subtree.FullName
            Try
                If subtree.GetDirectories().Length > 0 Or subtree.GetFiles().Length > 0 Then
                    subNode.SelectAction = TreeNodeSelectAction.SelectExpand
                    subNode.PopulateOnDemand = True
                    subNode.NavigateUrl = "#"
                End If
            Catch ex As Exception

            End Try
            node.ChildNodes.Add(subNode)
        Next subtree
        For Each fi As FileInfo In directory.GetFiles()
            Dim subNode As New TreeNode(fi.Name)
            node.ChildNodes.Add(subNode)
            subNode.NavigateUrl = "WebDocuments/" & fi.Name.ToString()
            'subNode.NavigateUrl = Server.MapPath(fi.Name.ToString())

Open in new window

LVL 2
bergertimeAsked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
Try

subNode.NavigateUrl = "/WebDocuments/" & fi.Name.ToString()

or

subNode.NavigateUrl = "~/WebDocuments/" & fi.Name.ToString()
0
 
bergertimeAuthor Commented:
Yeah, I tried that also, I get the same results.  If I click on a file in webdocuments then it works fine, if I click on a file that's in webdocuments/folder/doc.pdf then my url is site/webdocuments/doc.pdf.  It drops the subfolder.
0
 
CodeCruiserCommented:
To you add the subfolder to the navigateurl?
0
 
bergertimeAuthor Commented:
Not sure I understand?  Do I need to change my code above?
0
 
bergertimeAuthor Commented:
changed subNode.NavigateUrl = "WebDocuments/" & fi.Name.ToString()  to
subNode.NavigateUrl = "~/WebDocuments/" & node.text  & fi.Name.ToString()
0
All Courses

From novice to tech pro — start learning today.