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. Advertisements

  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. Advertisements

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. Matthew Louden
    Replies:
    1
    Views:
    7,573
    Scott M.
    Oct 11, 2003
  2. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    19,709
    Jon Skeet [C# MVP]
    Jun 9, 2004
  3. =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=

    Help on HTML server control vs HTML control

    =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=, Sep 15, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    2,304
    =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=
    Sep 15, 2005
  4. davetichenor
    Replies:
    1
    Views:
    1,092
    Eliyahu Goldin
    Oct 30, 2006
  5. Ken
    Replies:
    1
    Views:
    634
    Alvin Bruney
    Aug 16, 2003
  6. Dave
    Replies:
    0
    Views:
    1,204
  7. John Doh

    How to prevent BulletedList control from encoding HTML?

    John Doh, Feb 14, 2008, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    1,099
  8. Replies:
    2
    Views:
    644
Loading...