9

I have text that is retrieved on a linkbutton press:

enter image description here

When I press the button I am getting the following returned:

Test UAT's for release 2.2.0

It looks like HMTL entities are being retrieved. How do I turn these back into normal strings?

2 Answers 2

23

You don't need to remove the Html entities, actually the string that you are showing here is HTML Encoded so you just need to do Html Decoding to get it in normal form.

For that you have HttpUtility.HtmlDecode method.

string normalString = HttpUtility.HtmlDecode(myEncodedString);

If you are using .NET 4.0 or higher then you can also use WebUtility.HtmlDecode

Sign up to request clarification or add additional context in comments.

2 Comments

must reference System.Web.dll
Please, take mention about WebUtility.HtmlDecode as primary way. It is better, because does not require System.Web.dll
3

Use HttpUtility.HtmlDecode to decode the string.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.