带有“新行"的文本框 [英] Textbox with "new line"

查看:32
本文介绍了带有“新行"的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们尝试了几种方法来使文本框接受输入"、换行符等.但我们仍然面临同样的问题.大多数第三方"控件允许用户根据需要设置文本格式.例如,添加颜色、字体、表格等.但是,对于大多数时尚网站,我们不希望用户以这种方式格式化文本.

We tried several ways to make a textbox to accept the "enter", newline, etc.. But we are still facing the same problems. Most of the "Third party" controls allow the user to format the text as he wants. Eg, add color, font, table, etc.. However, for most stylish websites, we do not want to allow the user to format the text that way.

但我们仍然希望它们输入",因此我们禁用了大多数功能(颜色、粗体、表格、插入图像等).但是我们还有另一个问题,复制和粘贴.在文本框中看到从 MS Word 复制的人并不少见,网站的所有风格都很糟糕!

But we still want them to make "enter", so we disable most functions (Colors, bold, table, insert image, etc.). But we still have another problem, copy and paste. It is not uncommon to see people that copy from MS Word in the textbox and wham, all the style of the site is awful!

这就是为什么我打开了制作我自己的文本框的可能性,多行(ASP.Net),然后让制作权按Enter"(
).

That is why I turn on the possibility of making my own textbox, multiline (the ASP. Net) and just let the right to make press "Enter" (< br / >).

最好的方法是什么?

我有什么需要注意的提示吗?

谢谢!

推荐答案

设置模式为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 />")

这篇关于带有“新行"的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆