|
C#Create File Nodes
Listing 2. The CreateFileNode method creates a TreeNode object of type "file" and sets its appropriate properties, including where it should navigate to when a user clicks on it. Return the node to the calling code block so you can add it to a treeview. // Create file TreeNode from specified path
private TreeNode CreateFileNode(string sPath,
string sText)
{
// Create a node
TreeNode oNode = new TreeNode();
// Set the type to be file
oNode.Type = "file";
// Set the display text for the node
oNode.Text = sText;
// Setup the hyperlink
// Grab folder structure starting at project
// root
string sUrl = "/" +
sPath.Substring(MapPath("/").Length);
// Flip the slashes
sUrl = sUrl.Replace("\\", "/");
// Set the hyperlink
oNode.NavigateUrl = sUrl;
// Point target for hyperlink to iframe
oNode.Target="ifImages";
// Return the file node
return oNode;
}
|