Question

I am working in desktop application. I have string which is display in formatelinklabel control as HTML text. This HTML text contains special character like <, > and &. Because of these character, it is not display properly as HTML text.

My string is like this :

<b>Details: </b>  !"#$%'()*+,-/:;=?@[\]^_`{|}~&><)<br/> <b> Take: </b> test tab. <br/> <b>  Quantity: </b>  <br/><b> Days Supplied:  </b> 90 <br/>

When i tried to display this string in control it is not display like HTML formatted text and its format is broken and display plain text.

So Can anyone tell me how to escape these characters and display HTML text properly?

Thanks in Advance.

Était-ce utile?

La solution

Did you try to replace your special characters by their HTML code ?

For example, & could be replaced by &amp; . I did it with a C# project and it worked, I suppose it could be the same with VB.NET

You can find all codes here

Autres conseils

Simply use the String.Replace method on your string object and use the following link to replace the correct values

http://www.w3schools.com/tags/ref_entities.asp

Example:

string testStr = "!"#$%'()*+,-/:;=?@[\]^_`{|}~&><";
testStr = testStr.Replace("<", "&lt;");

Result : 

!"#$%'()*+,-/:;=?@[\]^_`{|}~&>&lt;

Notice that your < character has been replaced by the &lt; html should now render this correctly.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top