多行文本取段落文字

 

<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Height="145px"
        Width="279px"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" οnclick="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.         }
發佈了75 篇原創文章 · 獲贊 5 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章