多行文本取段落文字

来源:互联网 发布:mysql多表查询语句 编辑:程序博客网 时间:2024/05/01 03:15

 

<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" />

  1. protected void Button1_Click(object sender, EventArgs e)
  2.         {
  3.             //Response.Write(this.TextBox1.Text);
  4.             string s = this.TextBox1.Text.Trim(); 
  5.             string temp = "";
  6.             int count = 1;
  7.             if (s.Contains("/r/n"))
  8.             {
  9.                 while (true)
  10.                 {
  11.                     if (!s.Contains("/r/n"))
  12.                     {
  13.                         Response.Write("temp " + count + " == >" + s);
  14.                         break;
  15.                     }
  16.                     temp = s.Substring(0, s.IndexOf("/r/n", 0));
  17.                     if (temp == "")
  18.                     {
  19.                         s = s.Remove(0, temp.Length + 2);
  20.                         continue;
  21.                     }
  22.                     Response.Write("temp " + count + " ==> " + temp + "<br/>");
  23.                     s = s.Remove(0, temp.Length + 2);
  24.                     count++;
  25.                 }
  26.             }
  27.             else
  28.             {
  29.                 Response.Write("temp " + count + " ==> " + s);
  30.             }
  31.         }
原创粉丝点击