HyperLink control and HTML encoding

Discussion in 'ASP .Net' started by John A., Jun 7, 2010.

  1. John A.

    John A. Guest

    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;?
     
    John A., Jun 7, 2010
    #1
    1. Advertising

  2. 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;'>&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
     
    Andrew Morton, Jun 7, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    18,990
    Jon Skeet [C# MVP]
    Jun 9, 2004
  2. davetichenor
    Replies:
    1
    Views:
    881
    Eliyahu Goldin
    Oct 30, 2006
  3. Ken
    Replies:
    1
    Views:
    405
    Alvin Bruney
    Aug 16, 2003
  4. Dave
    Replies:
    0
    Views:
    977
  5. Replies:
    2
    Views:
    396
Loading...

Share This Page