MVC5 textarea 行列仅在明确指定而不是通过 htmlAttributes 指定时才起作用

joy*_*ym8 4 razor asp.net-mvc-5

@Html.TextAreaFor(model => model.DESCRIPTION, 20, 50, new { htmlAttributes = new { @class = "form-control"} })

问题:上面的代码正确显示 textarea 的行和列,但下面的代码忽略行/列并显示每个浏览器的默认大小。下面的代码有什么问题?

new以下代码中的额外内容是在创建 MVC 实体框架控制器时由 VS 自动创建的(如http://www.asp.net/mvc/overview/releases/mvc51-release-notes 中所述

@Html.TextAreaFor(model => model.DESCRIPTION, new { htmlAttributes = new { @class = "form-control", @rows="20", @cols="50"} })

Rol*_*oCC 6

这适用于 MVC 5.2.2:

@Html.TextAreaFor(model => model.Caracteristicas, new { @class = "form-control", @rows = "10" })
Run Code Online (Sandbox Code Playgroud)