HTML encoding of asp controls.

Discussion in 'ASP .Net' started by Guogang, Jan 21, 2004.

  1. Guogang

    Guogang Guest

    I find that the HTML encoding of asp web controls are inconsistent.

    Say, I want to show the string "<script> alter("test") <script>". For a
    "BoundColumn" used in DataGrid, I get an *real alert box* instead
    of the string. In order for it to be shown correctly, I have to call
    "Server.HtmlEncode" before set the text.

    But if I use "asp:TextBox" control, I can not do "Server.HtmlEncode"
    before I set the text. Otherwise, I will see this on my web page: "&lt;..."

    Is there a general rule, or documentation of which controls will do HTML
    encoding automatically, which don't?

    Thanks,
    Guogang
     
    Guogang, Jan 21, 2004
    #1
    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:
    19,049
    Jon Skeet [C# MVP]
    Jun 9, 2004
  2. Replies:
    1
    Views:
    23,571
    Real Gagnon
    Oct 8, 2004
  3. Guogang

    HTML Text encoding of web controls

    Guogang, Jan 8, 2004, in forum: ASP .Net Security
    Replies:
    1
    Views:
    183
    Felix Wang
    Jan 9, 2004
  4. Guogang

    HTML Text encoding of web controls

    Guogang, Jan 8, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    133
    Felix Wang
    Jan 9, 2004
  5. Guogang

    HTML encoding of asp controls.

    Guogang, Jan 21, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    106
    Guogang
    Jan 21, 2004
Loading...

Share This Page