ASP.MVC 3 Razor Add Model Prefix in the Html.PartialView extension

后端 未结 4 1821
野性不改
野性不改 2020-12-11 04:13

I have all most the same question as him ASP.NET MVC partial views: input name prefixes

I am tring to create CRUD operations for this data entities:

         


        
4条回答
  •  一生所求
    2020-12-11 04:31

    Try this extension:

    public static void RenderPartialWithPrefix(this HtmlHelper helper, string partialViewName, object model, string prefix)
            {
                helper.RenderPartial(partialViewName,
                                     model,
                                     new ViewDataDictionary { TemplateInfo = new System.Web.Mvc.TemplateInfo { HtmlFieldPrefix = prefix } });
            }
    

提交回复
热议问题