Rendering the field name in an EditorTemplate (rendered through EditorFor())

前端 未结 3 878
离开以前
离开以前 2020-12-13 14:53

I\'m currently building the Admin back-end for a website in ASP.NET MVC.

In an ASP.NET MVC application, I\'ve started using the \'EditorFor\' helper method like so:<

3条回答
  •  北海茫月
    2020-12-13 15:45

    Have been using this to generate id(with model prefix). Skip the .Replace() part if you want the name attribute.

    <%=Html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(String.Empty).Replace(".", HtmlHelper.IdAttributeDotReplacement) %>
    

提交回复
热议问题