Asp.net mvc 无法设置多行文本框mvc的大小

Asp.net mvc 无法设置多行文本框mvc的大小,asp.net-mvc,textarea,Asp.net Mvc,Textarea,有人能告诉我为什么这行不通吗?无论我对列和行使用什么,文本框的大小始终相同 @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 =

有人能告诉我为什么这行不通吗?无论我对列和行使用什么,文本框的大小始终相同


@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 })

或者您可以对
文本区域使用以下重载:

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" })