0

I'm using a repeater to create a table of contents. The data comes from a Web.sitemap file.

One page in the site is about List<T>, so the sitemap node looks like this:

<siteMapNode url="~/path-to-page" title="List&lt;T&gt;"/>

The output for this particular node becomes:

<a href="/path-to-page">List<t></t></a>

The angle brackets are turned into a nonsense HTML tag.

I've tried two other character entities and neither one gets output as actual angle brackets. The output is the same as above.

title="List&#60;T&#62;"
title="List&#x3C;T&#x3E;"

Before I go in and figure out some sort of string.Replace solution or something, I was wondering if I'm missing some other way of putting angle brackets in the sitemap file so they're output properly.

P.S. the ItemTemplate just has:

<asp:HyperLink runat="server" NavigateUrl='<%# Eval("Url") %>' Text='<%# Eval("Title") %>'>
</asp:HyperLink>
wazz
  • 4,953
  • 5
  • 20
  • 34

1 Answers1

0

As I was stepping through the results I realized that the angle brackets were not output in a weird way but actually as angle brackets, which is why they looked like HTML and produced the nonsense <t> tag.

I just had to HtmlEncode the output:

<asp:HyperLink runat="server" 
    NavigateUrl='<%# Eval("Url") %>' 
    Text='<%# Server.HtmlEncode(Eval("Title").ToString()) %>'>
</asp:HyperLink>
wazz
  • 4,953
  • 5
  • 20
  • 34