在 ASP.MVC 3 中,如何指定多行 EditorFor
(文本区域)的列和行?我正在使用 [UIHint("MultilineText")]
,但找不到任何有关如何为文本区域添加属性的文档。
所需的 HTML:
<textarea cols="40" rows="10"></textarea>
我的 MVC 3 模型的相关部分:
[UIHint("MultilineText")]
public string Description { get; set; }
我的 Razor cshtml 的相关部分:
<div class="editor-field">
@Html.EditorFor(model => model.Description)
</div>
我在查看源代码中得到了什么:
<div class="editor-field">
<textarea class="text-box multi-line" id="Description" name="Description"></textarea>
</div>
如何设置行和列?
最佳答案
使用 TextAreaFor
@Html.TextAreaFor(model => model.Description, new { @class = "whatever-class", @cols = 80, @rows = 10 })
或使用多行
类的样式。
您也可以写 EditorTemplate为此。
关于asp.net-mvc - 如何在 ASP.MVC 中指定多行 Editor-For 的列和行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6217908/