MVC 3 client-side validation on collection with data annotations — not working

百般思念 提交于 2019-12-01 13:03:58

Try using Editor Templates in your view:

@Html.EditorFor(x => x.newsItems)

and inside ~/Views/Shared/EditorTemplates/NewsItemDetails.cshtml:

@model AppName.Models.NewsItemDetails

// bunch of stuff
// then:
<div class="editblock">
    @Html.TextAreaFor(model => model.newsBody, new { @class = "formtextem", id = editBoxID, rows = "10", style = "width: 54em" })
    @Html.ValidationMessageFor(model => model.newsBody)
</div> 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!