首页 > 技术文章 > 在TextBox中显示换行的文字以及将换行的文字显示在页面上保存换行的文字

hc10 2013-10-15 21:19 原文

string bulletinContent = this.Server.HtmlEncode(txtcontent.Text.ToString().Replace("'", "")).Replace("\r\n", "<br/>").Replace(" ", " ");

将有换行文字的字符串显示在TextBox中,原来是换行的,在TextBox中显示的也是换行的:

txtcontent.Text = board.BulletinContent.Replace("<br/>","\r\n");

推荐阅读