SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am taking a value from a string from a text column

String str = myListItem[field name].toString()

In many cases the field may contain html which I wish to remove but it is somehow not visibly contained in str. When str is output to the webpart it still has the html tags.

How can I return the field value with the html tags in the text?

share|improve this question
Sean, you mean the text contains HTML and you want to treat is as a string and show up on Label ? – Arsalan Adam Khatri Nov 12 '12 at 7:46

use Server.HtmlDecode(string) Server.HtmlEncode(string) to encode and decode HTML.

share|improve this answer
Welcome to SharePoint.SE! While this post may answer the question, we prefer more details such as "why". Please edit your post with additional details. See How to Answer for general guidelines. – Kit Menke Nov 13 '12 at 19:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.