且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

带有“新行"的文本框

更新时间:2023-12-03 13:06:58

设置模式为TextBoxMode.MultiLine

在代码隐藏中,

myTextBox.TextMode = TextBoxMode.MultiLine

或在标记​​中

<asp:TextBox TextMode="MultiLine"

当用户在 TextBox 中输入文本时,它会以 形式返回给您.如果您想正确地向用户显示它,您可以使用

When the user enters text in the TextBox, it will come back to you with new lines as . If you'd like to display it properly to the user, you could use

myTextBox.Text.Replace(Environment.NewLine, "<br />")