look at HttpServerUtility.HtmlEncode() and HttpServerUtility.HtmlDecode() methods
Strip all HTML code from String with C#
-
09-03-2022 - |
Pergunta
I am currently pulling some data from a SQL Server database into a C# asp.net page.
I am using the following (portion of) code to ouput the HTML text that is stored in my body
column:
TextLabel.Text += "<div class=\"newsEntry\">" +
Convert.ToString(reader2["body"]).Substring(0, 220) +
"...<a href='entry.aspx?ID=" + reader2["ID"] +
"' title=\"Read More about " + reader2["Title"] +
"\">Read More »</a></div>";
I'd like to strip the body value (+ Convert.ToString(reader2["body"]).Substring(0, 220) +
) of all HTML inside it.
How do I achieve this with C#?
Normally with PHP, I'd use striptags
.
Many thanks for any help.
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow