By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 733 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

Problem with code

P: n/a
I got this code from the Internet. Demo on the site works fine but downloaded version is not.
I am a very new to .NET, I cannot figure this out, please help.
Here is the code:
ASPX code:
<%@ 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>

c# code:
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
}
}

Here is the error:
Server Error in '/shark' Application.
--------------------------------------------------------------------------------

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'shark.TreeView.DocTree'.

Source Error:
Line 1: <%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls" %>
Line 2: <%@ Page language="c#" Codebehind="DocTree.aspx.cs" AutoEventWireup="false" Inherits="shark.TreeView.DocTree" %>
Line 3: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
Line 4: <HTML>
Source File: C:\Program Files\Microsoft Visual FoxPro 7\testarea\dotnet\treeview\shark\doctree.aspx Line: 2
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
you are missing the "shark.TreeView.DocTree" control

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Mark" <an*******@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
I got this code from the Internet. Demo on the site works fine but downloaded version is not. I am a very new to .NET, I cannot figure this out, please help.
Here is the code:
ASPX code:
<%@ 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></t
d><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>
c# code:
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
}
}

Here is the error:
Server Error in '/shark' Application.
-------------------------------------------------------------------------- ------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error
details and modify your source file appropriately.
Parser Error Message: Could not load type 'shark.TreeView.DocTree'.

Source Error:
Line 1: <%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls"
Assembly="Microsoft.Web.UI.WebControls" %> Line 2: <%@ Page language="c#" Codebehind="DocTree.aspx.cs" AutoEventWireup="false" Inherits="shark.TreeView.DocTree" %> Line 3: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
Line 4: <HTML>
Source File: C:\Program Files\Microsoft Visual FoxPro 7\testarea\dotnet\treeview\shark\doctree.aspx Line: 2

-------------------------------------------------------------------------- ------ Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

Nov 18 '05 #2

P: n/a
Are you saying I have to add a form with aTreeView control on in to the project? Sorry for stupid questions.
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.