how to prevent coding mess up submit text?

Discussion in 'C#' started by wacamoi, Jan 10, 2009.

  1. #1
    Assume there is a form to submit text and will be showed later.

    It will allow users to key in codes or java or any scripts.

    But the Question is: How to only show their in html/text form and do not they run in server? Any simple way?


    Thanks,
     
    wacamoi, Jan 10, 2009 IP
  2. nyxano

    nyxano Peon

    Messages:
    417
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I am not sure I understand the question... are you saying that people can post scripts, html, asp, php, etc code in a text box only to be displayed on a page later - but not run? Just like you can include code here and wrap it in a
     tag?
    
    Simplest way store the posting in a variable then have ASP replace all < with &lt; and > with &gt;
    
    This way, the symbols will still appear on the web page, but scripts won't run.
    Code (markup):
     
    nyxano, Jan 11, 2009 IP
    wacamoi likes this.
  3. deltron

    deltron Active Member

    Messages:
    397
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    73
    #3
    I am not entirely sure what you mean... but maybe this will help.

    try surrounding the text in <pre> ... </pre> tags. This makes the browser not render the text.

    i.e.

    lblShow.text = "<pre>" & txtText.text & "</pre>"
     
    deltron, Jan 11, 2009 IP
    wacamoi likes this.
  4. gnp

    gnp Peon

    Messages:
    137
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Specifically for ASP code, you do not have to worry as this runs before any dunamic content is added.

    So if you disaply asp code from a variable or a databse it would not execute.. It would be treated as standard text..

    javascript, html etc. though which are interpreted by the browser will be executed unless you encode them for html as nyxano suggested.
     
    gnp, Jan 13, 2009 IP
  5. phone00x

    phone00x Guest

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i think it's not easy
     
    phone00x, Jan 13, 2009 IP