Click here to Skip to main content
13,299,898 members (62,575 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 23 Sep 2010

How to remove Hyperlink from ASP.NET TreeView Nodes Control Nodes?

, 23 Sep 2010
Rate this:
Please Sign up or sign in to vote.
A post on how to remove Hyperlink from ASP.NET TreeView Nodes Control Nodes

ASP.NET Tree view control is rendered as HTML Table – TR –TD elements. Each of the nodes has been represented as hyperlinks. Sometimes, you may not want those fields as hyperlinks and you want those nodes to be represented as static text. Many of the developers did the same using font style or CSS style change of the node, but it can be done very easily. In this small blog post, I am going to describe how you can represent a tree view node as simple text instead of hyperlink.

This can be done very easily using Tree Nodes, SelectionAction properties. SelectionAction has 4 different values. They are:


Select is the default option which marks node as hyperlinked and on selection of the node, it raises SelectedNodeChanged event. For Expand Option, TreeNodeExpanded event will be raised while expanding the node. “SelectExpand” raises both the SelectedNodeChanged and TreeNodeExpanded events. Now if you don’t want to make the node as simple text, just change the SelectionAction properties to “None”.


The above image shows how you can change the “SelectionAction” properties while creating a TreeView manually. But most of the time, bind the data from a data source with tree view dynamically, for that you can use the code snippet given below:


So, what does this “Select” and “None” really make change internally? Yes, when you are using Selection Action as “Select” Treeview Nodes rendered as HTML hyperlink in UI but for the “None” it rendered as "Span

The below image shows the “Span” element of TreeNode for “SelectionAction=”None””.


The below image shows the hyperlink mode of TreeNode for “SelectionAction=”Select””.



In this blog post, I have described how you can use a TreeView node without hyperlink mode. There was a question that was asked over here, where I gave the same answer. So, I thought of sharing with all of you with some detailed explanation.

Hope this will help you!


Filed under: ASP.NET, ASP.NET 4.0, Tips and Tricks


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Abhijit Jana
Technical Lead
India India
.NET Consultant | Former Microsoft MVP - ASP.NET | CodeProject MVP, Mentor, Insiders| Technology Evangelist | Author | Speaker | Geek | Blogger | Husband

Blog :
Web Site :
Twitter : @AbhijitJana
My Kinect Book : Kinect for Windows SDK Programming Guide

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
neD802-Mar-12 4:45
memberneD802-Mar-12 4:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171207.1 | Last Updated 24 Sep 2010
Article Copyright 2010 by Abhijit Jana
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid