我知道你可以使用EditorFor html助手中的DataType属性来指定模型实体的特定属性应显示为多行输入字段。
如果我想指定文本区域必须具有的行数和列数怎么办?
在模型中:
```csharp [DataType(DataType.MultilineText)] public string MyProperty { get; set; } ```
您可以在模型中使用MultilineText数据类型,然后在视图中使用TextAreaFor html助手。例如:
```csharp @Html.TextAreaFor(m => m.MyProperty, new { rows = 4, cols = 40 }) ```[DataType(DataType.MultilineText)]
public string HTMLText { get; set; }
在视图中:
@Html.EditorFor(x => x.HTMLText)
期望的结果:
<textarea id="HTMLText" rows="10" cols="40">value</textarea>
有没有一种方法可以在不使用@Html.Textarea()助手的情况下生成这种代码?