Link to File on Local Server from TreeView Web Page
In a TreeView TreeNode, you can set the NavigateUrl property to link to a web resource (http/ftp).
What if you want to link to a file path? (file://)
You can do it (for browsers such as IE that support it), but you can't use the 'NavigateUrl', or it will replace spaces with %20 signs in the file path. This will cause the links to not work.
Instead, leave NavigateUrl null on the TreeNode.
Then, set the node's Text property to a raw anchor tag.
You must surround the file path by literal quote marks to get the browser to read it properly.
Your text should look like this:
myNode.Text = " < a target=\"_blank\" href=\"" + urlPath + "\"> " + displayName + " < /a> "
where urlPath is a file path like: file:////server/sub folder/file name.txt
(change local backslashes to forward slashes for readability)
Note that I put 4 slashes after "file:". This isn't required for IE (only 2 required), but helps in other browsers (4 expected).
Created By: amos 8/22/2013 12:14:19 PM
Updated: 8/22/2013 12:27:04 PM