2017-06-20 131 views
0

谁能告诉我为什么这不会工作?无论我用什么排列,文本框始终是相同的大小不能设置多行文本框的大小mvc

@ Html.TextAreaFor(model => model.Report.EmailMessage,new {htmlAttributes = new {@class =“form-control” ,@cols = 100,@rows = 20}})

回答

0

您可以删除html属性,下面的代码应该可以工作。

@Html.TextAreaFor(model => model.Report.EmailMessage, new { @class = "form-control", @cols = 100, @rows = 20 }) 
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" }) 

Relevant link to MSDN article.