Accessing ASP.NET TreeView Node Attributes

Posted on 2008-11-03
Last Modified: 2012-05-05
Does anyone know if there is a way to access the innerHTML or innerText properties of a TreeNode object?

There are only a few methods accessible for the Nodes of a TreeViewNodes object collection including Text, NavigateURL, ImageURL and Target. But I am wanting to add a custom attribute to the Node (not TreeView) level such as "rel=nofollow" to the Node's <a> tag.

There seems to be no way to do this on the Server side.

Does anyone have a solution that might work on either the Server or Client script side?

Question by:deeisner
    LVL 20

    Expert Comment

    I think that YourTreeView.Node(yourNode).Attributes.Add("rel","nofollow") should work.

    Author Comment

    no, there is no Attribute or Attributes property at the TreeNode level. Only for the container TreeView object. Thanks though
    LVL 20

    Accepted Solution


    Well, then you can create your own TreeNode, and use it instead of the default one.
    Here is a good example:



    Author Closing Comment

    Great idea, thank you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now