任何人都可以告诉我为什么这不起作用?无论我用什么用于cols&行,文本框总是相同的大小
@ Html.TextAreaFor(model => model.Report.EmailMessage,new {htmlAttributes = new {@class =" form-control",@ cols = 100,@rows = 20}})
答案 0 :(得分:0)
您可以删除html属性,以下代码应该有效。
@Html.TextAreaFor(model => model.Report.EmailMessage, new { @class = "form-control", @cols = 100, @rows = 20 })
答案 1 :(得分:0)
或者您可以对TextAreaFor
使用以下重载:
public static MvcHtmlString TextAreaFor<TModel, TProperty>(
this HtmlHelper<TModel> htmlHelper,
Expression<Func<TModel, TProperty>> expression,
int rows,
int columns,
object htmlAttributes
)
产:
@Html.TextAreaFor(model => model.Report.EmailMessage, 20, 100, new { @class = "form-control" })