Opening file present in treeview by clicking on it within a table? I had created a table with a row and two columns. in one column i had dislayed treeview and want that if i click on the file in treeview it gets opened in other column. Can this happen?

I also got a code in some website related to my problem but there are errors in this code that i am not able to understand can you correct those errors:
using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.Web.UI.WebControls;
namespace shark.TreeView
/// <summary>
/// Summary description for DocTree.
/// </summary>
public class DocTree : System.Web.UI.Page
protected Microsoft.Web.UI.WebControls.TreeView TreeCtrl;
public DocTree()
Page.Init += new System.EventHandler(Page_Init);
private void Page_Load(object sender, System.EventArgs e)
if ( ! this.IsPostBack )
// add tree node "type" for folders and files
string imgurl = "/shark/webctrl_client/1_0/Images/";
TreeNodeType type;
type = new TreeNodeType();
type.Type = "folder";
type.ImageUrl = imgurl + "folder.gif";
type.ExpandedImageUrl = imgurl + "folderopen.gif";
TreeCtrl.TreeNodeTypes.Add( type );
type = new TreeNodeType();
type.Type = "file";
type.ImageUrl = imgurl + "html.gif";
TreeCtrl.TreeNodeTypes.Add( type );
// start the recursively load from our application root path
// (we add the trailing "/" for a little substring trimming below)
GetFolders( MapPath( "~/./" ), TreeCtrl.Nodes );
// expand 3 levels of the tree
TreeCtrl.ExpandLevel = 3;
private void Page_Init(object sender, EventArgs e)
InitializeComponent();
// recursive method to load all folders and files into tree
private void GetFolders( string path, TreeNodeCollection nodes )
// add nodes for all directories (folders)
string[] dirs = Directory.GetDirectories( path );
foreach( string p in dirs )
string dp = p.Substring( path.Length );
if ( dp.StartsWith( "_v" ) )
continue; // ignore frontpage (Vermeer Technology) folders
nodes.Add( Node( "", p.Substring( path.Length ), "folder" ) );
// add nodes for all files in this directory (folder)
string[] files = Directory.GetFiles( path, "*.aspx" );
foreach( string p in files )
nodes.Add( Node( p, p.Substring( path.Length ), "file" ) );
// add all subdirectories for each directory (recursive)
for( int i = 0; i < nodes.Count; i++ )
if ( nodes[ i ].Type == "folder" )
GetFolders( dirs[ i ] + "\\", nodes[i ].Nodes );
// create a TreeNode from the specified path, text and type
private TreeNode Node( string path, string text, string type )
TreeNode n = new TreeNode();
n.Type = type;
n.Text = text;
if ( type == "file" )
// strip off the physical application root portion of path
string nav = "/" + path.Substring( MapPath( "/" ).Length );
nav.Replace( '\\', '/' );
n.NavigateUrl = nav;
// set target if using FRAME/IFRAME
n.Target="doc";
return n;
#region Web Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
this.Load += new System.EventHandler(this.Page_Load);
#endregion
and the design that i got on website for the code that i displayed just above it is
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls" %>
<%@ Page language="c#" Codebehind="DocTree.aspx.cs" AutoEventWireup="false" Inherits="shark.TreeView.DocTree" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript (ECMAScript)" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body>
<form id="DocTree" method="post" runat="server">
<table height="100%" cellSpacing="0" cellPadding="8" border="0">
<tr height="100%">
<td vAlign="top">
<iewc:treeview id="TreeCtrl" runat="server" SystemImagesPath="/shark/webctrl_client/1_0/treeimages/">
</iewc:treeview>
</td>
<td vAlign="top" width="100%" height="100%">
Click on any *.aspx page in the tree and it should load here <iframe id="doc" name="doc" frameBorder="yes" width="100%" scrolling="auto" height="100%">
</iframe>
</td>
</tr>
</table>
</form>
</body>
</HTML>
This is my code for viewing treeview but it is not expanding plz help me in this also
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;
using System.Media;
using System.Drawing;
using System.Drawing.Imaging;
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
if (Page.IsPostBack == false)
System.IO.DirectoryInfo RootDir = new System.IO.DirectoryInfo(Server.MapPath("~/Files"));
// output the directory into a node
TreeNode RootNode = OutputDirectory(RootDir, null);
// add the output to the tree
MyTree.Nodes.Add(RootNode);
TreeNode OutputDirectory(System.IO.DirectoryInfo directory, TreeNode parentNode)
// validate param
if (directory == null) return null;
// create a node for this directory
TreeNode DirNode = new TreeNode(directory.Name);
// get subdirectories of the current directory
System.IO.DirectoryInfo[] SubDirectories = directory.GetDirectories();
// OutputDirectory(SubDirectories[0], "Directories");
// output each subdirectory
for (int DirectoryCount = 0; DirectoryCount < SubDirectories.Length; DirectoryCount++)
OutputDirectory(SubDirectories[DirectoryCount], DirNode);
// output the current directories file
System.IO.FileInfo[] Files = directory.GetFiles();
for (int FileCount = 0; FileCount < Files.Length; FileCount++)
DirNode.ChildNodes.Add(new TreeNode(Files[FileCount].Name));
} // if the parent node is null, return this node
// otherwise add this node to the parent and return the parent
if (parentNode == null)
return DirNode;
else
parentNode.ChildNodes.Add(DirNode);
return parentNode;
This is my design
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style2
width: 412px;
.auto-style3
width: 174px;
.auto-style4
width: 743px;
.auto-style5
width: 506px;
height: 226px;
</style>
</head>
<body>
<form id="form1" method="post" runat="server">
<table align:"center" class="auto-style4" border="1" style="table-layout: fixed; border-spacing: 1px">
<tr>
<td class="auto-style3">
<br />
<br />
<br />
<br />
</td>
<td class="auto-style2">
<br />
<br />
<br />
<br />
</td>
</tr>
<tr>
<td class="auto-style3" valign="top">
<asp:TreeView Id="MyTree" PathSeparator = "|" ExpandDepth="0" runat="server" ImageSet="Arrows" AutoGenerateDataBindings="False">
<SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px" VerticalPadding="0px" ForeColor="#5555DD"></SelectedNodeStyle>
<NodeStyle VerticalPadding="0px" Font-Names="Tahoma" Font-Size="10pt" HorizontalPadding="5px" ForeColor="#000000" NodeSpacing="0px"></NodeStyle>
<ParentNodeStyle Font-Bold="False" />
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD"></HoverNodeStyle>
</asp:TreeView>
</td>
<td class="auto-style2">
<base target="_blank" /> <iframe frameborder="0" scrolling="yes" marginheight="0" marginwidth="0"
src="" class="auto-style5"></iframe>
</td>
</tr>
</table>
</form>
</body>
</html>

Hi meghage,
From your code, it is a WebForm project.
This forum is to discuss problems of Windows Forms. Your question is not related to the topic of this forum.
You can consider posting it in asp.net forum for supports . Thanks.
ASP.NET: http://forums.asp.net
Regards,
Youjun Tang
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

Maybe you are looking for

  • URM How to set default value in the "New Check-in" - "Folder" field

    Hello everyone, I'm trying to find out how to set the default value for the "folder" field in a check-in profile created using the Configuration Manager. If I browse to the folder in the "Browse Content -> Folders" menu and check-in a file inside the

  • ITunes can't find any of my music

    I've been using iTunes for a long time now. I keep all my music on an external (portable) drive with the exception of podcasts or downloaded music from the store. All of a sudden iTunes can't find any of my music. Everytime I click on a song to play

  • Dark Prints with Photoshop CS3 and CS4 but not Lightroom

    Hi, To start,I have calibrated my dell monitor with eye-one pro as well as my epson 7800. i am running vista 64 bit on my PC... When i use photoshop (CS3 or CS4) the images look fine on the screen and come out really dark on the printer. When i use l

  • I can not activate my iPhone 3gs. What is the problem ? why ? Solutions ?

    Good day! I just bought an Iphone 3gs and  I did an update and now I can not activate it. It says : the actiivation server is temporary unavaliable. When Iam trying to do throught iTunes it says that there is no sim card (((. This is my first iphone.

  • [Solved]Webcam Creative Live not working

    Hi, I think there's a problem with one of the latest updates, my webcam was working fine since before myself@Desktop ~]$ dmesg |tail usb 2-2: USB disconnect, address 3 gspca: disconnect complete usb 3-1: new full speed USB device using uhci_hcd and a