Question

I just updated a page to use a DetailsView in asp.net. It included a MultiLine textbox, which is now in the EditItemTemplate of the details view. The problem is that when outputting this data (which is stored in the database), I was replacing vbCrLf (a new line contant --> VB, Carriage Return, Line Feed) with <br/>, which worked fine before, but now that it is in the details view its like the vbCrLf doesn't exist and after the replace(str, vbCrLf, "<br/>"), instead of there being a HTML break (<br/>) where the textbox had linebreaks, it all just displays in one line. How can I fix this? Thanks.

Was it helpful?

Solution

Try Environment.NewLine instead

OTHER TIPS

Set the htmlEncode to false

if you're taking data out of the database, that contains newlines, then just leave those there and the textArea should work just fine... you don't need to do a replace with "<BR/>"... you only need to do that if you're putting the text into the page as HTML... but you're trying to fill an input control, so unless you're doing something else that isn't clear, you don't need to do the replace

With a textarea control, the long texts seems like they have line breaks, but sometimes they don't have line breaks. If the text reaches the length of the text area, it continues at the second line, but it's not contain a line break. If user presses enter, then a new line break will be added to your content.

I think you're missing that point.

Hope it helps.

I've always replaced the character code--chr(10) in VB.NET--with a <br /> to show my line breaks. Give that a try?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top