文本框与"新的生产线和QUOT;文本框、生产线、QUOT

2023-09-07 13:06:23 作者:不思量自难忘°

我们尝试了几种方法可以使一个文本框接受输入,换行,等等。但我们仍然面临着同样的问题。大多数的第三者控制允许用户为他想格式化文本。例如,添加颜色,字体,表等。然而,最时尚的网站,我们不希望允许用户在文本的方式进行格式化。

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的网络)的可能性,只是让做preSS输入(小于BR />)的权利。

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

无论是在C-背后的$ C $,

Either in the code-behind,

myTextBox.TextMode = TextBoxMode.MultiLine

或在标记​​

or in the markup

<asp:TextBox TextMode="MultiLine"

当用户输入的文本框的文本,它会回来给你新的行作为 \ r \ñ。如果你想正确地显示给用户,你可以使用

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

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