need help with Treeview

 I want to use a treeview for a navingation purpose,

the tree view needs to be populated with nodes,  based on the type of user logged in.  Depending on the security of the user i.e User role.. some nodes should be shown and some hide.

I see this being achieved in one of 1.1  framework project, but i am not able to use the same code for 2.0 frame work.

below is the code:


using System;
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;
using Microsoft.Web.UI.WebControls;

namespace BCS.WebContent
/// <summary>
/// Summary description for ContentLinks.
/// </summary>

public class leftNav : System.Web.UI.Page

protected Microsoft.Web.UI.WebControls.TreeView treeview1;

protected String TreeViewCssClass="TreeView_Text_STD";//String.Empty;

private void Page_Load(object sender, System.EventArgs e)
string srcPath=@"../XML/NavLinkSrc/";

if (!Page.IsPostBack)
//Add a new Treeview control
treeview1=new TreeView();
// --- SECURITY --->
if(Context.User.IsInRole("System Admin"))
treeview1.TreeNodeSrc=Server.MapPath(srcPath + "AdminLinks.xml");
else if(Context.User.IsInRole("NC Admin"))
treeview1.TreeNodeSrc=Server.MapPath(srcPath + "NCSuperUserLinks.xml");
else if(Context.User.IsInRole("NC User"))
treeview1.TreeNodeSrc=Server.MapPath(srcPath + "NCUserLinks.xml");
else if(Context.User.IsInRole("NC View"))
// Added 31/01/2006 - DNC - Task 1728
treeview1.TreeNodeSrc=Server.MapPath(srcPath + "NCUserLinks.xml");
else if(Context.User.IsInRole("NC Tax"))
// Added 01/11/2006 - DNC - Task 1327
treeview1.TreeNodeSrc=Server.MapPath(srcPath + "NCTaxLinks.xml");
else if(Context.User.IsInRole("Test User"))
// Added 10/20/2008 - Kumaran - Aldon 8065 - Add New User group ('Test User')
treeview1.TreeNodeSrc=Server.MapPath(srcPath + "TestUserLinks.xml");
treeview1.TreeNodeSrc=Server.MapPath(srcPath + "GuestLinks.xml");
treeview1.SystemImagesPath = "/webctrl_client/1_0/treeimages/";

Page.Controls.Add(treeview1); //Add control
catch(Exception ex)

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
// CODEGEN: This call is required by the ASP.NET Web Form Designer.


/// <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);




one of the XML file used to populate  the tree node


BODY{font:x-small 'Verdana';margin-right:1.5em} ..c{cursor:hand} ..b{color:red;font-family:'Courier New';font-weight:bold;text-decoration:none} ..e{margin-left:1em;text-indent:-1em;margin-right:1em} ..k{margin-left:1em;text-indent:-1em;margin-right:1em} ..t{color:#990000} ..xt{color:#990099} ..ns{color:red} ..dt{color:green} ..m{color:blue} ..tx{font-weight:bold} ..db{text-indent:0px;margin-left:1em;margin-top:0px;margin-bottom:0px;padding-left:.3em;border-left:1px solid #CCCCCC;font:small Courier} ..di{font:small Courier} ..d{color:blue} ..pi{color:blue} ..cb{text-indent:0px;margin-left:1em;margin-top:0px;margin-bottom:0px;padding-left:.3em;font:small Courier;color:#888888}{font:small Courier;color:#888888} PRE{margin:0px;display:inline}0) fix(e,"cb");} if (e.className=="di"){if (e.children(0).innerText.indexOf("\n")>0) fix(e,"db");}""; } function fix(e,cl){ e.className=cl;"block"; j=e.parentElement.children(0); j.className="c"; k=j.children(0);"visible"; k.href=""; } function ch(e){ mark=e.children(0).children(0); if (mark.innerText=="+"){ mark.innerText="-"; for (var i=1;i

 <?xml version="1.0" encoding="utf-8" ?>
- <TreeNode Text="System Management">
  <TreeNode Text="User Administration" NavigateUrl="../common/getDocument.aspx?pageTitle=User Administration&scriptName=../WebAdmin/UserList.aspx" Target="mainframe" />
  <TreeNode Text="Create ArtiCAD Price File" NavigateUrl="../WebAdmin/prices_ArtiCAD.aspx" Target="mainframe" />
  <TreeNode Text="Change Password" NavigateUrl="../common/ChangePassword.aspx?required=false" Target="mainframe" />
  <TreeNode Text="Sign Out" NavigateUrl="../Logout.aspx" Target="_top" Hidden="true" />




 when I try to do the same thing for my project , using .net 2.0 and C#


i get an error saying "TreeNodeSrc" is not a valid property of treeview.



Can anyone please help me out.... how can I use Treeview in 2.0  and bind the nodes depending on the role of the User.

will be waiting for reply...





5/4/2009 6:56:02 PM 13714 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 29


  First create a treenode for the treeview.

     TreeNode newnode=new TreeNode (text);
  and assign the newnode navigation url inthe if conditions.

newnode.NavigateUrl="specify the navigation url"

 Finally at the end add the node to the treeview

TreeView1.Nodes.Add(newnode );

R.charan kumar

Please mark the most helpful reply/replies as "Answer".
5/5/2009 4:17:23 AM

Similar Artilces:

TreeView Control Loading Issue/Help Needed - URGENT
I am building a database driven application that will be used over the internet. I am currently using a database driven TreeView control for navigation around the web applications many pages. I am also using Master pages on this application. I have placed the TreeView control on the master page and I load the TreeView from my SQL server DB on the page load event, when IF NOT ISPOSTBACK is TRUE, on the Master Page. My problem is that every single postback event on any of my content pages causes the reload of the TreeView control. This is completely unnecessary as the contents of the...

Need help for treeView control
hi:I have these codes: protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)    {        string id = "consequence";        Response.Redirect("../Content/Consequence.aspx?nodeID=" + id);        TextBox1.Text = "Node is selected!";    }Currently, after a tree node is clicked. The TextBox1 doesn't display any data. Any help will be appreciated. The reason is because you redirected current request to another url so code never can reach t...

Need some help with searching a TreeView control
I need some help in getting a node to be selected and all parents explanded in a TreeView where ALL the nodes are populated on demand. I'm envisioning a search page with a Gridview but with no TreeView.  In the Gridview's results will be a hypertext column that will take the user to another page that will have the TreeView on it with the ID of the node to be selected in the querystring.When a result is clicked I want the TreeView to expand as needed with the selected node selected. Since the TreeView is populated on demand I'm thinking that I'm going to have to wr...

Need Help with Menu navigation Control
I m a noob at VS I want to develop an application using, and I want to use the Menu navigation control along with Sitemap is there any tutorial from where I get to learn this from scratch and 2nd thing is I would be requiring some skins/themes for the menu so kindly redirect me to a site if u know any Thanks n regardsA87 ASP.Net NoobLearning now will contribute later :) Well, this is easy to answer: scroll the page up and click Get Started in the menu. When you have asked a question, remember to click "Mark as answered" for a reply that answered...

Need Help with IE TreeView Control
 Hi friends !!I have used a IE tree view control on a page in DIV tag.but there is some problem with it, many times when I tries to select any option in tree view the focus is set to the top of tree view and that option still remains unselected.......But this tree view control will perfect when I'll remove DIV tag....can anybody plz help me out this ....     i'll wait for and answer....thanks !!Just let me code for[at]gmail.comSoftware Developerworking for a US Based CMM5 MNC PUNE INDIA...

need help in forum user navigation control
Hi I want to build this type of user navigation as is usually used in web forums site name > forumsgroupname > forum name > post/thread name i.e. Web Design > Web Design > HTML Forum and Tutorials > please help with frame navigation can any body give me idea how to achieve it, or from where i can get this sort of user control or how can develope my own. thanx tj...

Need help with navigation question (.NET and Javascript?)
Hi!I have a question regarding .NET and Access databases. I have a number of products in my db, with id numbers to identify category. The user interface is to look like the following:  Is it possible to produce such a "navigation" with .NET and Access database?Help appriciated! /Anders  Check below link ASP.NET Image Gallery Hope this helps,Haissam Abdul MalakMCAD.NET| Blog |...

Help Needed" Treeview Control"
Hi fellow programmers I have been sitting with this problem now for last week and going out of my mind. Assistance needed baddly. My problem is that when i select a specific folder from my recreated treeview control, the subdirectories is displayed at the buttom instead of underneath the selected directory.Thats problem one. Problem two is how do i get the number of directories contained within a specified directory without writing a hetic piece of code. A sample of my code is attached. Use at your own discretion. Any help will be gladly appreciated. 'setting value to my varia...

Data in Treeview-control (Problem
I have a problem when i'm trying to fill the treeview with the data. The data is hiërarchical so I work with ParentID...Help would be deeply appreciated Here is the error I get whenever i load the page: [FormatException: De indeling van de invoertekenreeks is onjuist.] Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) +252 Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value) +44 Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value) +136[InvalidCastException: De conversie van teke...

I need JavaScript help to remove a cookie built in a .NET custom control!
Hi, I have a custom login control that creates a cookie to store the user's ID and password.  The purpose of the cookie is to only require the user to sign-in once per day (it has a 10 hour life span).  Some users are not comfortable with this, so in addition to an 'Exit' button on my web pages, I want to add a 'Sign-Off' button that would immediately destroy their cookie.  I'm trying to do this in JavaScript, but no matter what I try I can't remove the cookie.  I don't know if it matters that the cookie was not created in JavaScript, or what my problem is.  An...

Menu Navigation Control Overlapping with Text Labels
Hi, everyone.  I'm stuck with a pretty (seemingly) basic problem.  I've created a Menu Navigation control that is oriented horizontally across the top of my Web Form.  The Menu itself works fine - I can see all of the dynamic menu items no problem. The problem is this...  I've got some text elements (in a separate Label control) as part of my web page immediately below the menu.  When I hover the mouse over the menu so that the dynamic menu items drop down, I can see the text drawn right over the menu (as if the menu is in the background and the Label control were i...

Making a Treeview checkbox in VB.Net from Xml. Need Help [:'(]
Hi, I am using Visual Studio 2005 to create a window application. I am trying to make it interact with an xml file. I am a newbie at both VB.Net and Xml that's why I really need help in making a treeview checkbox in VB.Net from an xml file. My idea is as follows:  The structure XML file (say named file.xml) is messy and unorganized but still in the correct node group. <main>   <child1>      <type1>good</type1>      <type2>evening</type2>      <type1>morn...

I need help with creating the correct .NET validation control for a text field
I have an edit control on an .aspx page. I need to validate the controlso that it matches the way the data type is defined in the database. In the database the column name ReportedPurchasePrice is definedas follows: ReportedPurchPrice (decimal(19,4),null) This value that is stored in this column is obtained from the following edit control in the .aspx file: <TR><TD width="<%=leftMargin%>"></TD><TD><asp:textbox id="ReportedPurchPrice" Width="250" CssClass="Normal" runat="server"></asp:textbox></TD...

Custom Server Control - Moving within the VS.Net Designer
Hi, I have created a custom server control that inherits from System.Web.UI.Control. I would like my end users to be able to drag and move the server control in the VS.Net IDE. I presume I have to expose the left/top style properties but can't find anything in the documentation or via google. Any pointers, links or code would be great :) R Hmmm, Inherit from System.Web.UI.WebControls.WebControl or just use the default Create Web Control project in the .Net IDE Can't believe I spent 1 hour looking for this :) Any element can be movable in VS.NET. What it really does is ...

Need help with dynamic controls in a custom control
I've overridden the datagrid to create a custom control. Right now all I'm trying to do with it is emulate the pager control and have the page numbers print out as a link to click. I am getting page numbers, but they aren't wiring up to the event handlers I've created. I've included the code and what it's outputting. Any help would be greatly appreciated. Code: protected override void Render(RootSystem.Web.UI.HtmlTextWriter writer) { writer.Write("<table border=\"0\">"); writer.Write("<tr><td>"); for (int l_intIndex...

Web resources about - need help with Treeview -

Live-Beta TreeView Demo: Frameless Layout with Highlighting TreeView Demo: Frameless Layout with Highlighting ...
Welcome to our beta site for CBC Live mp3 streams! This is a form of online broadcast we are exploring right now, both from a technical best-practices ...

Visual Basic for Applications - Wikipedia, the free encyclopedia
Visual Basic for Applications ( VBA ) is an implementation of Microsoft 's event-driven programming language Visual Basic 6 and its associated ...

From the Saint
It's full steam ahead for events in the Saint today; although some have been postponed, others are getting bigger and better.

HOME - St. Catharines
St. Catharines is a city that offers many ammenities and opportunities to its residents. It is a place known for its friendliness, charm and ...

CrossFont Help
CrossFont Help

Examples - AlloyUI
AlloyUI is a framework built on top of YUI3 that provides a simple API for building high scalable applications. — all software.
Xara X1 1.1 DL Xara X is an advanced graphic illustration package for Windows, that offers unrivaled redraw speed and a user interface which ...

CrossFont Help
CrossFont Help

Evolution of the Windows Interface
... a 3D button, comboboxes. Windows 95 introduced a slew of new 3D controls, such as rich text edit, toolbars/statusbar, progressbar, treeview/listview, ...

Silverlight - Blackboard
Silverlight is a development platform for creating rich media applications and business applications for the Web, desktop, and mobile devices.Microsoft ...

Resources last updated: 1/19/2016 5:16:48 PM