Textarea doesn't show newline in IE

2019-06-26 09:35发布

Looks like IE ignores \r\n in text when the text is placed into a textarea. Here's how it looks in FF/Chrome/Opera:

Paragraph1 sometext
Paragraph2 othertext

And in IE7/8:

Paragraph1 sometextParagraph2 othertext

I tried changing "new-line" css parameter with no luck. Any ideas what might be wrong?

I use asp.net as back end, where I assign that text to the textarea, but I doubt it's relevant.

UPDATE: Seems like it's asp.net that is rendering asp:TextArea differently for different browsers - for IE it seems to ignore newline characters. When I replace asp:TextBox with textarea, I get correct results. Any ideas how to fix that?

4条回答
成全新的幸福
2楼-- · 2019-06-26 10:00

A newline is \r\n, not \n\r. Yes, it makes a difference.

查看更多
小情绪 Triste *
3楼-- · 2019-06-26 10:00

textbox with "MultiLine" set to "TextMode" is the rendering to so this is not the problem...

查看更多
Deceive 欺骗
4楼-- · 2019-06-26 10:02

Turns out that my problem has nothing to do with the textarea itself, but rather with the way I'm escaping the output and unescaping the input. I'll open another question for that problem.

查看更多
萌系小妹纸
5楼-- · 2019-06-26 10:15

I had the same issue, where if specifying the width for the TextBox that was marked as TextMode="MultiLine" was causing the above behavior. I solved it manually specifying Rows and Columns properties of the textbox.

查看更多
登录 后发表回答