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

ampersand characters

4 Answers 83 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Spire
Top achievements
Rank 1
Spire asked on 04 Oct 2011, 03:17 PM
Hi,

I using some ampersand characters in my treeview, but when I validate my page with http://validator.w3.org I get some error on the ambersand characters.

Line 146, Column 132StartTag: invalid element name
…x?Category=$VingepumpeMindre250&amp;menyCategory=1,1">Vingepumper, <250 bar</a>

<telerik:RadTreeNode Text="Vingepumper, &lt;250 bar" NavigateUrl="~/preview.aspx?Category=$VingepumpeMindre250&menyCategory=1,1" ></telerik:RadTreeNode>

Is it possible to make the treeview control to show ambersand?


Best regards
Aksel Henriksen

4 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 05 Oct 2011, 01:18 PM
Hello Spire,

It appears the RadTreeView doesn't html encode the Text property, but somehow does the opposite, it html decodes it. So if you enter it like you did or just enter "<", it will always render it as "<" to the browser.

Maybe this is a bug with the RadTreeView or maybe there is a reason it does it this way.
0
Nikolay Tsenkov
Telerik team
answered on 07 Oct 2011, 10:45 AM
Hello Kevin,

Actually RadTreeView encodes the Text property when rendering it. But getting the value from the text property should return the initially inserted.

Regards,
Nikolay Tsenkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Accepted
Kevin
Top achievements
Rank 2
answered on 07 Oct 2011, 01:09 PM
Hello Nikolay,

I don't see any html encoding of any kind going on with the RadTreeView control. It seems to html decode the Text property when you add it in the designer and just takes that text as is when you add it from the code-behind. Try this and tell me what the html source is:

Designer:
<telerik:RadTreeView ID="RadTreeView1" runat="server">
        <Nodes>
            <telerik:RadTreeNode Text="1 < 2">
            </telerik:RadTreeNode>
            <telerik:RadTreeNode Text="1 &lt; 2">
            </telerik:RadTreeNode>
        </Nodes>
    </telerik:RadTreeView>

Code-Behind:
RadTreeView1.Nodes.Add(new RadTreeNode("2 < 3"));
RadTreeView1.Nodes.Add(new RadTreeNode("2 &lt; 3"));

The one's in the designer both show as 1 < 2 in the html source, the one's added from the code-behind get added as is. Do you not get the same effect?

I'm using version 2011.2.712.35 of the controls.
0
Accepted
Nikolay Tsenkov
Telerik team
answered on 13 Oct 2011, 09:38 AM
Hello Kevin,

This is the default behavior for ASP.NET controls.

You can test the same scenario using the asp:TreeView and the same will be rendered:

<asp:TreeView runat="server" ID="TreeView1">
    <Nodes>
        <asp:TreeNode Text="1 < 2" />
        <asp:TreeNode Text="1 &lt; 2" />
    </Nodes>
</asp:TreeView>


Regards,

Nikolay Tsenkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
TreeView
Asked by
Spire
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Nikolay Tsenkov
Telerik team
Share this question
or