谁能告诉我为什么这不起作用?无论我对cols和rows使用什么,文本框总是相同的大小
@ Html.TextAreaFor(model => model.Report.EmailMessage,new {htmlAttributes = new {@class =“form-control”,@ cols = 100,@rows = 20}})
您可以删除html属性,以下代码应该可以工作 .
@Html.TextAreaFor(model => model.Report.EmailMessage, new { @class = "form-control", @cols = 100, @rows = 20 })
或者您可以为 TextAreaFor 使用以下重载:
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" })
Relevant link to MSDN article.
2 回答
您可以删除html属性,以下代码应该可以工作 .
或者您可以为
TextAreaFor
使用以下重载:生产环境 :
Relevant link to MSDN article.