SnagQueensHubby
SnagQueensHubby

Reputation: 185

How do I programmatically put line breaks into a textarea

I am using a textarea field to display the status of a form submission. The form itself allows the user to delete one or more images.

Currently the textarea is showing:
1234.pdf has been deleted. 5678.pdf has been deleted. (no line-breaks)

I'd like it to look like:
1234.pdf has been deleted.
5678.pdf has been deleted.

I've tried putting in <br/> (which then shows the <br/> in the text, but doesn't cause a line break) and I've tried Environment.NewLine, which seems to get ignored and ends up showing the first example above.

What am I doing wrong?

Upvotes: 0

Views: 1590

Answers (3)

ZeroWorks
ZeroWorks

Reputation: 1638

Both:

<textarea rows="10" cols="30">
1234.pdf has been deleted.
5678.pdf has been deleted.
</textarea>

and

<textarea rows="10" cols="30">
1234.pdf has been deleted.&#10;5678.pdf has been deleted.
</textarea>

should work. So if you write output from PHP for example just put \n or &#10; at the end of every string and will work. If you use C# or vb.net use (char)10 for C# or chr(10) for .vb.

Fiddler

Upvotes: 1

Ignacio Laborde
Ignacio Laborde

Reputation: 1462

Try using &#10

<textarea rows="10" cols="30">
  I'm playing &#10 in the garden.
</textarea>

Upvotes: 1

Ford Filer
Ford Filer

Reputation: 325

Use line feed and carriage return characters

line 1 &#13;&#10; line 2

the &#13;&#10; should make a line break

Proof this works: JSFiddle

Upvotes: 3

Related Questions