This is a migrated thread and some comments may be shown as answers.

Issue with dynamically adding nodes to treeview with node value contains '<'

1 Answer 151 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Somnath
Top achievements
Rank 1
Somnath asked on 22 Sep 2011, 09:59 AM
Hi ,

I am treeview control.
I am adding nodes dynamically using following code.
Nodes are actually database column names.


RadTreeNode tnAttr = new RadTreeNode(attr.Name); // Here attr.Name is "Category<ID"
tnAttr.ToolTip = attr.LongDescription;
 
treeViewDimension.Nodes.Add(tnAttr);

In Internet Explorer 8 i am getting scriptresource error ,hence the node is not visible in treeview but it generating space .

while in Firefox it is working but text is cutting down to "Category".

This is hapening when we are sending node values contains "<".

Please suggest for same .We need to allow '<' character in treeview

1 Answer, 1 is accepted

Sort by
0
Accepted
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 22 Sep 2011, 12:13 PM
Try this

string category = HttpContext.Current.Server.HtmlEncode(attr.Name); //It's in System.Web if you dont have a reference
  
RadTreeNode tnAttr = new RadTreeNode(category);
tnAttr.ToolTip = HttpContext.Current.Server.HtmlEncode(attr.LongDescription);
   
treeViewDimension.Nodes.Add(tnAttr);

HttpContext.Current.Server.HtmlEncode should encode the special characters for you so they're actually coming out as characters like these...but the browser renders them normally.
Tags
General Discussions
Asked by
Somnath
Top achievements
Rank 1
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Share this question
or