Try our conversational search powered by Generative AI!

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

Vote:
 

Hi all!

I have front end code like this:

<p>
<%= CurrentPage.MainBody.Replace (Environment.NewLine, "</p><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></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></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!

#57587
Mar 22, 2012 10:01
Vote:
 

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

#57610
Mar 23, 2012 8:00
Vote:
 

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.

#57697
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.