HyperLink control and HTML encoding

  • Follow


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;&#39;>&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;?
0
Reply John 6/7/2010 1:56:11 PM

John A. wrote:
> 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;&#39;>&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.

-- 
Andrew 


0
Reply Andrew 6/7/2010 2:05:08 PM


1 Replies
585 Views

(page loaded in 0.068 seconds)


Reply: