hncl
hncl

Reputation: 2305

asp.net mvc - convert <br> to <br/> in c#

My application is ASP.NET MVC2 C#, I am using Telerik MVC Editor and itextsharp to produce a PDF file. My challenge is <br /> shows in the PDF rather than a new paragraph.

In the editor I have:

.Encode(false)

In the controller I am using:

er.Comments = HttpUtility.HtmlDecode(recommendation.Comments);

so far everything works well.

To produce my PDF, I am using:

BPR = HttpUtility.HtmlEncode(this.Recommendations.**Comments**)
List<IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(BPR ), null);

Comments is stored as in the database as:

First Paragraph <br /> Second paragraph

However when I debug the program, BPR is converted to:

First Paragraph &lt;br /&gt; Second paragraph

Is there a way to convert &lt;br /&gt; back to <br/>?

Upvotes: 0

Views: 4977

Answers (1)

hncl
hncl

Reputation: 2305

The problem was in this line:

BPR = HttpUtility.HtmlEncode(this.Recommendations.Comments)

Since I getting the values from a database some of the data were already encoded.

Upvotes: 2

Related Questions