well i have tried again and yet again failed.
i can only think i am approaching this from totally the wrong angle so if u can point me in right direction that would be grand.
The .aspx file is as so.
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TreePage.aspx.cs" Inherits="TreePage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="stname" runat="server" Text="Label"></asp:Label>
<asp:TreeView ID="fronttree" runat="server"></asp:TreeView>
</div>
</form>
</body>
</html>
with the code behind .cs file like this.
Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class TreePage : System.Web.UI.Page
{
private ACustomTree st;
protected void Page_Load(object sender, EventArgs e)
{
st = new ACustomTree();
stname.Text = st.Name + "node count = " + st.Nodes.Count;
fronttree = st;
//i have also just tried
//fronttree = new ACustomTree();
//didnt work either.
}
public class ACustomTree : TreeView
{
private String name;
public String Name {
get
{
return name;
}
set
{
name = value;
}
}
public ACustomTree()
{
name = "test tree name";
addNodes();
}
private void addNodes()
{
TreeNode ROOT = new TreeNode("ROOT");
this.Nodes.Add(ROOT);
ROOT.ChildNodes.Add(new TreeNode("123"));
ROOT.ChildNodes.Add(new TreeNode("321"));
ROOT.ChildNodes.Add(new TreeNode("222"));
ROOT.ChildNodes.Add(new TreeNode("333"));
}
}
}
all that i get displayed is the string saying
"test tree namenode count = 1"
and no TreeView whatsoever.
hopefully u r like right now and can see a noob trap i have fallen into but alas i cant see it lol
obviously the problem is the assigning back to the fronttree object and it not being drawn properly, but alas i am not sure how to fix that.
pootles off to keep fiddling and hopfully falls over the solution lol.
cheers
Jon