【发布时间】:2017-11-23 06:52:58
【问题描述】:
谁能告诉我为什么这行不通?无论我对列和行使用什么,文本框的大小始终相同
@Html.TextAreaFor(model => model.Report.EmailMessage,new { htmlAttributes = new { @class= "form-control", @cols = 100, @rows = 20 } })
【问题讨论】:
标签: asp.net-mvc textarea
谁能告诉我为什么这行不通?无论我对列和行使用什么,文本框的大小始终相同
@Html.TextAreaFor(model => model.Report.EmailMessage,new { htmlAttributes = new { @class= "form-control", @cols = 100, @rows = 20 } })
【问题讨论】:
标签: asp.net-mvc textarea
您可以删除 html 属性,下面的代码应该可以工作。
@Html.TextAreaFor(model => model.Report.EmailMessage, new { @class = "form-control", @cols = 100, @rows = 20 })
【讨论】:
或者您可以为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" })
【讨论】: