@{var items = new String[] { "abc", "def", "ghi" };}
<textarea rows="3" cols="39">
@foreach (var item in items) {
@(item + Environment.NewLine)
}
</textarea>
@Html.Raw(获取值+ "\n");
@{string _html=string.Empty;} @foreach(var QuestionOption in template.QuestionList[num-1].QuestionOptions ) { _html+=@QuestionOption.Value+"\n"; } <textarea>@Html.Raw(_html)</textarea>
设置好宽度就自动会换行了,保存的时候在转换下S_Encode(txtcontent.Text.Trim())就ok了。转换函数如下,记得修改的时候要转回来
public static string S_Encode(string str)
{
str = str.Replace("&", "&");
str = str.Replace("'", "''");
str = str.Replace("\"", """);
str = str.Replace(" ", " ");
str = str.Replace("<", "<");
str = str.Replace(">", ">");
str = str.Replace("\n", "<br>");
return str;
}