HTMLencode HTMLdecode

后端 未结 3 1750

I have a text area and I want to store the text entered by user in database with html formatting like paragraph break, numbered list. I am using HTMLencode and HTMLdecode fo

3条回答
  •  渐次进展
    2021-01-13 14:56

    The simple solution would be to do:

    string str1 = Server.HtmlEncode(TextBox1.Text).Replace("\r\n", "
    ");

    This is assuming that you only care about getting the right
    tags in place. If you want a real formatter you will need a library like Aaronaught suggested.

提交回复
热议问题