多行文本框多个换行符
我为 Multiline Textbox
设置了一个值,如下所示。
textBox1.Text = "Line1\r\n\r\nLine2";
但是,输出中只有一行空间。
当我读取文本框的值时,我读取了 "Line1\r\nLine2"
;
为什么 ASP.NET 不支持多于一个的行行字符?
I set a value for a Multiline Textbox
like this.
textBox1.Text = "Line1\r\n\r\nLine2";
But, only one line space in output.
When I read the value of textbox, I read "Line1\r\nLine2"
;
Why does ASP.NET not support more then one lineline character?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您需要将文本框设置为多行,可以通过两种方式完成:
在控件中:
代码隐藏:
这将呈现为
You need to set the textbox to be multiline, this can be done two ways:
In the control:
Code Behind:
This will render as a
<textarea>
此外,标记还需要包含 TextMode="MultiLine" (否则它将文本显示为一行)
Also the markup needs to include TextMode="MultiLine" (otherwise it shows text as one line)
试试这个
对我来说工作得很好...
Try this one
Working fine for me...
我也有同样的问题。如果我添加一个Environment.Newline,我会在文本框中得到一个新行。但如果我添加两个Environment.Newline,我会得到一个新行。
在我的网络应用程序中,我使用空白模块来删除所有不必要的空白。如果我禁用此模块,我的文本框中会出现两行新行。希望有帮助。
I had the same problem. If I add one Environment.Newline I get one new line in the textbox. But if I add two Environment.Newline I get one new line.
In my web app I use a whitespace modul that removes all unnecessary white spaces. If i disable this module I get two new lines in my textbox. Hope that helps.
当页面IsPostback时,以下代码可以正常工作。但是,当页面首次加载时,文本区域中没有多个换行符。漏洞
When page IsPostback, the following code work correctly. But when page first loading, there is not multiple newline in the textarea. Bug
拖动文本框本身时,按F4键设置属性,并将文本模式设置为多行,多行在文本框中的表示是它可以在6边上调整大小。并且不需要包含任何换行字符来获取多行。可能您将其设置为多行,但您没有在设计时增加文本框的大小。
While dragging the TextBox it self Press F4 for Properties and under the Textmode set to Multiline, The representation of multiline to a text box is it can be sizable at 6 sides. And no need to include any newline characters for getting multiline. May be you set it multiline but you dint increased the size of the Textbox at design time.
textBox1.Text = "Line1\r\r\Line2";
解决了问题。
textBox1.Text = "Line1\r\r\Line2";
Solved the problem.