2017-06-20 36 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.