textArea中的NewLine字符

时间:2012-01-25 22:14:15

标签: asp.net-mvc-3 c#-4.0 textarea encode

这是我的代码

控制器

public ActionResult Sites()
{
    var viewModel =  new ViewModel();
    viewModel.currentSite.genComments =HttpUtility.HtmlEncode("Some string that</br>\r\n looks like this<br/>"); 
    return View(viewModel);
}

查看:

@Html.EditorFor(v => v.currentSite.gencomments, Model.currentSite.gencomments, "gencomments")

我收到一条错误消息,指出路径中存在无效字符。 任何想法或建议

1 个答案:

答案 0 :(得分:0)

您是否打算让评论指定模板名称?看起来你正在调用EditorFor的this overload

尝试

@Html.EditorFor(v => v.currentSite.gencomments, "gencomments")

要命名该字段,您可以尝试这个(虽然不能保证这个!):

@Html.EditorFor(v => v.currentSite.gencomments, "gencomments", "gencomments", null)
相关问题