来自专栏一个爱瞎折腾的程序猿
mvc一对多模型表单的快速构建
而后发现大神写的一个HtmlPrefixScopeExtensions扩展类,可自动生成的表单前缀标识,使用方便,也能够使用验证
只需将表单包裹在@using (Html.BeginCollectionItem Layout = null;
}
@model MvcDemo.Models.CaseModel
@using MvcDemo.Extensions
@using (Html.BeginCollectionItem (html, collectionName, html.ViewContext.Writer);
}
private static IDisposable BeginCollectionItem (this IHtmlHelper html, string collectionName)
{
return BeginCollectionItem(html, collectionName, html.ViewContext.Writer);
}
private static IDisposable BeginCollectionItem
2K20发布于 2018-09-14