Whi*_*and 16 html c# asp.net-mvc multiline asp.net-mvc-3
我正在使用C#开发一个MVC项目.现在,我正在尝试稍微调整我的观点,我想让文本框更大.
我按照这个问题中的建议从单行移动到多行文本字段: 更改Html.TextBox的大小
现在我正在尝试调整多行字段的大小,但我不确定在哪里或如何这样做.
以下是我的编辑视图中的片段
<div class="editor-label">
     @Html.LabelFor(model => model.Body)
</div>
<div class="editor-field">
     @Html.EditorFor(model => model.Body)
     @Html.ValidationMessageFor(model => model.Body)
</div>
从我的模型:
[DataType(DataType.MultilineText)]  
[DisplayName("Body:")]  
public string Body { get; set; }
Dar*_*rov 19
我会用CSS做到这一点:
<div class="editor-multiline-field">
     @Html.EditorFor(model => model.Body)
     @Html.ValidationMessageFor(model => model.Body)
</div>
然后在CSS文件中将宽度和高度定义为所需的值:
.editor-multiline-field textarea {
    width: 300px;
    height: 200px;
}
Ped*_*tre 15
您也可以使用@ Html.TextArea ou TextAreaFor
@Html.TextAreaFor(model => model.Text, new { cols = 25, @rows = 5 })
在MVC 5中你可以使用
    @Html.TextAreaFor(model => model.body, 5, 50,  new { @class = "form-control" } )
很好用!
| 归档时间: | 
 | 
| 查看次数: | 28705 次 | 
| 最近记录: |