How to handle HTML tag info in control?

I tried to use Server.HtmlEncode to solve this problem, but to find it still doesn't work.

temp=Server.HtmlEncode(content.Text);




Answer this question

How to handle HTML tag info in control?

  • nitesh_garg

    Some people rendered HTML tag to attack website, some others did this for normal purpose.

    For those different clients, how to solve this problem

     

    Did i make it clear Thank you for your help in advance!

     



  • gafrank

    What's the problem Do you wish to display the HTML the way it would look rendered (take a look at the WebBrowser control), or do you want to display the HTML itself

    Please clarify your post.

  • MMS2006

    I think I get it now... You're building a website where people can enter text in a control, and you would like to make it possible to use HTML tags for text markup, but you don't want to make it possible that people attack your website by entering for instance script tags, right

    A typical solution for this is to let the users use these brackets: [ and ]. In your code, you can find and replace these brackets with < and >. But only in cases where you would like to allow tags.

    Another solution is to make buttons which a user can use to for instance make text bold or italic. In the back, you can mark the text to be made up with a special sign, or just use [ and ] and the replace option.

  • yeos_lee

    many thks, Rick!

  • How to handle HTML tag info in control?