文本区域中的换行符

发布于 2024-12-28 18:30:23 字数 473 浏览 4 评论 0原文

这是我的代码

Controller

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);
}

View:

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

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

Here is my code

Controller

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);
}

View:

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

I get an error saying that there are invalid characters in the path.
Any ideas or suggestions

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自由如风 2025-01-04 18:30:23

您是否打算让注释指定模板名称?看起来您正在调用 EditorFor 的此重载

尝试仅

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

命名该字段,您可以尝试此操作(但不能保证这一点!):

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

Are you intending for the comments to specify the template name? It looks like you are calling this overload of EditorFor.

Try just

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

To name the field, you can try this (no guarantees on this one though!):

@Html.EditorFor(v => v.currentSite.gencomments, "gencomments", "gencomments", null)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文