Paragraphs in a property, when text comes from an asp:textbox


Hi all!

I have front end code like this:

<%= CurrentPage.MainBody.Replace (Environment.NewLine, "</p><p>" %>

And back end code that takes the value of an asp:textbox multiline and puts it into MainBody. You would think that the paragraphs should be ok but no. The rendered html code looks like this:

<p> Nunc vel orci vitae lorem placerat tristique. Suspendisse libero nulla, lobortis eu facilisis quis, laoreet non libero. In et velit nulla. Suspendisse potenti. Sed et tellus porttitor risus condimentum cursus ut eget nulla. Etiam eu lacus nisi, id tempus dolor. </p>
<p>Donec ut diam velit, eu rhoncus ante. Cras eget volutpat lorem. In ultrices enim sed est tempor vel egestas ante consectetur. Integer tincidunt vulputate erat, sit amet dapibus nibh rutrum quis. </p>
<p>Aliquam vel placerat justo. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras tristique, arcu vel pellentesque congue, felis metus sagittis metus, at pulvinar eros sapien non lectus. </p>

Where do the extra <p></p> with nothing in them come from? Can I get rid of them?


Thanks in advanced!

Mar 22, 2012 10:01

Is there a way to make the user input in an asp:textbox formated with <p></p>? That each paragraphs get <p></p>?

Mar 23, 2012 8:00

I would use a Regex and put P-elements around text that ends with two line breaks. Replace one line break with BR. I would also store the content as HTML so that editors can view it inside EPi in a Editor-field.

Mar 24, 2012 0:53
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.