Reputation: 6509
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.
Upvotes: 1
Views: 906
Reputation: 281
look at HttpServerUtility.HtmlEncode() and HttpServerUtility.HtmlDecode() methods
Upvotes: 3