MVC 5.1.2 EditorFor htmlAttributes

时间:2014-04-23 20:44:35

标签: editorfor

这看起来很简单:

@ Html.EditorFor(m => m.FirstName,new {htmlAttributes = new {@class =" form-control"},}

但是,发出的页面没有应用此类。

2 个答案:

答案 0 :(得分:1)

@Html.EditorFor(model => model.FirstName, new { htmlAttributes = new { @class = "form-control" } })

这似乎对我有用,你在那里有一个逗号,并且未能正确关闭paranthesis。

答案 1 :(得分:0)

MVC编辑器助手期望additionalViewData对象作为该参数。这在ASP.Net MVC 5.1中得到了更好的处理,但目前,将EditorFor交换为TextBoxFor应该可以很好地处理这个问题。