2017-06-19 29 views
0

我有一个文本区域,用户必须写一个描述。我想知道如何设置一个文本框,以便它在多行,允许用户看到他们正在写什么。我所寻找的是类似我写在这个问题上的环境你如何使一个HTML.EditorFor文本框存在多行?

<div class="form-group"> 
    <div class="col-md-10"> 
     @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } }) 
    </div> 
</div> 
+0

你需要一个Textarea的权利? – User3250

回答

1

在你的模型,你需要MultilineText添加如下:

[DataType(DataType.MultilineText)] 
public string Title { get; set; } 
1

或者你的代码已经只是改变了EditorFor为TextAreaFor like下面

@Html.TextAreaFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } }) 
相关问题