我的问题,如果用户在多文本文本框中输入一个句子/单词,并按下输入按钮 那么该单词被压入beuton应存储在数据库中。 表示如果用户以格式输入一个文本区域 1 GB 2 GB 3 GB 80 GB 作为过滤器选项,则在数据库中这些应该存储为不同的行。希望你了解我的问题。多行文本框
Q
多行文本框
0
A
回答
1
所以你的用户输入:
1GB
2GB
3GB
80GB
,并要分割的,所以你可以将它们保存在数据库中四个不同的记录?
在字符串上使用Split
函数可以根据字符串分隔符将字符串分割为数组。在你的情况下,我们会使用一个换行符分割原始文本字符串:
protected void Button1_Click(object sender, EventArgs e)
{
string textLines;
string[] textLine;
textLines=MultilineTextBox.Text;
textLine = textLines.Split(Environment.NewLine.ToArray(), StringSplitOptions.RemoveEmptyEntries);
// At this point the textLines array will have four entries in it, one for each line in the textbox on the form
}
然后,您可以遍历数组的行保存到数据库中。
0
我会建议更好地使用文本框单行和列表框的组合。但是,如果你想有一个多行TextBox(和没有Ajax)来看看:
function checkEnter(e){
var characterCode
if(e && e.which){
e = e
characterCode = e.which
} else {
e = event
characterCode = e.keyCode
}
if(characterCode == 13){
var txt=document.getElementById('<%= TextBox1.ClientId%>');
txt.blur();
}
}
function moveCursorToEndOfTextBox(){
var txt=document.getElementById('<%= TextBox1.ClientId%>');
txt.focus();
txt.value = txt.value+'\n';
}
<asp:TextBox ID="TextBox1" onkeypress="checkEnter(this)" AutoPostBack="true" OnTextChanged="TextChanged" TextMode="MultiLine" runat="server"></asp:TextBox>
和代码隐藏:
Protected Sub TextChanged(ByVal sender As Object, ByVal evt As EventArgs)
Dim allLines As New List(Of String)(Microsoft.VisualBasic.Strings.Split(Me.TextBox1.Text.Trim, vbCrLf))
Dim newLine As String = allLines(allLines.Count - 1)
'save new item to db .....
'register script to jump into textbox and got to end of text
ScriptManager.RegisterStartupScript(Me, Me.GetType, "moveCursorToEndOfTextBox", "moveCursorToEndOfTextBox();", True)
End Sub
相关问题
- 1. 多行文本框
- 2. 筛选多行文本框
- 3. 多行文本框列C#
- 4. HTML5 Canvas多行文本框
- 5. Windows Phone多行文本框
- 6. jQuery的 - 多行文本框
- 7. OCaml + LablGTK2:多行文本框
- 8. 无法从单行文本框更改为多行文本框
- 9. 使用Javascript在多行显示文本[多行文本框]
- 10. 对话框中的多行文本框
- 11. 多行文本框中的当前行
- 12. .NET多行文本框 - 设置行数
- 13. 在多行文本框中降序文本(精简框架,C#)
- 14. 将多行文本粘贴到单行文本框中
- 15. 多行文本框显示多行字符串为单行
- 16. 多行文本框在颤动
- 17. DataGridView中的多行文本框
- 18. PyQt多行文本输入框
- 19. C#多行文本框错误
- 20. 多行文本框的点击事件
- 21. iphone中的多行文本框
- 22. wxPython:静态框中的多行文本
- 23. Telerik Kendo MVC文本框多行模式
- 24. RegularExpressionValidator多行文本框缓慢(textarea)
- 25. 多行文本框属性android?
- 26. itext多行文本在边界框中
- 27. 多行复选框文本格式
- 28. Silverlight中的多行文本框
- 29. Telerik Wpf RadControls多行文本框
- 30. nativescript中的多行文本框
家庭作业?请告诉我们你的代码。 – adatapost 2010-07-14 13:26:12