HyperLink control and HTML encoding

J

John A.

If I have a hyperlink control like this:

<asp:HyperLink ID="HyperLink1" runat="server"
Text="&'><"
ToolTip="&'><"
NavigateUrl="~/">
</asp:HyperLink>

it renders as:

<a id="HyperLink1" title="&amp;'>&lt;" href="/">&'><</a>

Am I to understand that the Text attribute's value is never encoded, and
the ToolTip's value is encoded by default? If so, according to what
rules, since the > is not converted to &gt;?
 
A

Andrew Morton

John said:
If I have a hyperlink control like this:

<asp:HyperLink ID="HyperLink1" runat="server"
Text="&'><"
ToolTip="&'><"
NavigateUrl="~/">
</asp:HyperLink>

it renders as:

<a id="HyperLink1" title="&amp;'>&lt;" href="/">&'><</a>

Am I to understand that the Text attribute's value is never encoded,
and the ToolTip's value is encoded by default? If so, according to
what rules, since the > is not converted to &gt;?

It looks like the Text attribute is taken literally - otherwise you couldn't
put any markup in it.

As long as all the < are encoded, the > don't need to be.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top