适用于大型文本区域的MVC3 HTML Helper

Mik*_*ebb 5 html-helper asp.net-mvc-3

我有一个HTML帮助器:

@Html.EditorFor(model => model.Description)
Run Code Online (Sandbox Code Playgroud)

但它对于我的模型的属性中的数据来说太小了.Descriptino是一个1000个字符的字符串.我需要用户能够输入几行文本并将其包装在HTML对象中.我该怎么做呢?

jpe*_*rez 25

尝试

Html.TextAreaFor(model => model.Description, new {@cols="80" , @rows="4" })
Run Code Online (Sandbox Code Playgroud)


jav*_*iry 6

使用:

@Html.TextAreaFor(model => model.Description)

// or a full option-list is:
@Html.TextAreaFor(model => model.Description, 
    rows, // the rows attribute of textarea for example: 4
    columns, // the cols attribute of textarea for example: 40
    new { }) // htmlAttributes to add to textarea for example: @class = "my-css-class"
Run Code Online (Sandbox Code Playgroud)

注意:您可以使用null而不是new { }for,htmlAttributes但不建议使用!强烈建议使用空白new { }- 表示new object-