<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Height="145px"
Width="279px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
- protected void Button1_Click(object sender, EventArgs e)
- {
- //Response.Write(this.TextBox1.Text);
- string s = this.TextBox1.Text.Trim();
- string temp = "";
- int count = 1;
- if (s.Contains("/r/n"))
- {
- while (true)
- {
- if (!s.Contains("/r/n"))
- {
- Response.Write("temp " + count + " == >" + s);
- break;
- }
- temp = s.Substring(0, s.IndexOf("/r/n", 0));
- if (temp == "")
- {
- s = s.Remove(0, temp.Length + 2);
- continue;
- }
- Response.Write("temp " + count + " ==> " + temp + "<br/>");
- s = s.Remove(0, temp.Length + 2);
- count++;
- }
- }
- else
- {
- Response.Write("temp " + count + " ==> " + s);
- }
- }
本文介绍如何在ASP.NET中处理多行文本框(TextBox)的内容,通过Button点击事件,提取并显示文本框内的段落。示例代码展示了如何利用字符串操作方法获取文本段落。
1517

被折叠的 条评论
为什么被折叠?



