我有一个字符串保存到数据库中。问题是它只在我处于编辑模式表单时显示换行符。当我只是在我的网页中显示它(不编辑)或在电子邮件中使用它时,字符串显示时没有换行符,并且它们都一起运行(见下图)。我正在使用 MVC 4 和 VS2012。
谁能告诉我如何让换行符始终显示?
该字符串是从具有以下代码的表单生成的:
string LF = " \r\n ";
//string LF = Environment.NewLine; // tried this also, did'nt work.
string appendComments = " ";
contact.Subject = "Quick Quote";
appendComments += "Make Sure to Contact Customer by: " + Request.Form["radio"].ToString(); ;
appendComments += LF + LF + "CARPET CLEANING: " + LF;
if ((Request.Form["bedRms"]) != "0") { appendComments += "Bedrooms =" + Request.Form["bedRms"] + ", " + LF; }
if ((Request.Form["familyRm"]) != "false" || (Request.Form["familyRm"]) == "on" ) { appendComments += "Family Room = Yes, " + LF; }
if ((Request.Form["livingRm"]) != "false" || (Request.Form["livingRm"]) == "on") { appendComments += "Living Room = Yes, " + LF; }
if ((Request.Form["diningRm"]) != "false" || (Request.Form["diningRm"]) == "on") { appendComments += "Dining Room = Yes, " + LF; }
if ((Request.Form["ld-combo"]) != "false" || (Request.Form["ld-combo"]) == "on") { appendComments += "Living/Dining Combo = Yes, " + LF; }
if ((Request.Form["pets"]) != "false" || (Request.Form["pets"]) == "on") { appendComments += "Pet Spot/Stain Issue = Yes " + LF; }
Here I save it to the database.
编辑表单中的换行作品:编辑表单中的 作品 http://www.leadingedgewebsites.com/linefeedworks.jpg
换行在网页上显示时 不起作用:在网页上不起作用 http://www.leadingedgewebsites.com/linefeednowork.jpg
换行在电子邮件中不起作用:在电子邮件 中不起作用 http://www.leadingedgewebsites.com/inemail.jpg
我非常感谢你抽出时间来帮助我。
谢谢你。