简体   繁体   English

如何使HTML.EditorFor文本框存在多行?

[英]How do you make a HTML.EditorFor textbox exist on multiple lines?

I have a text area where users have to write a description. 我有一个文本区域,用户必须在其中编写说明。 I was wondering how to set a text box so that it is on multiple lines, allowing the user to see what they are writing. 我想知道如何设置一个文本框,使其位于多行上,从而允许用户查看他们在写什么。 What I am looking for is similar to the environment that I am writing this question in. 我正在寻找的内容类似于我在撰写此问题的环境。

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

In your model you need to add MultilineText as below: 在模型中,您需要添加MultilineText,如下所示:

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

或者您的代码刚刚将EditorFor更改为TextAreaFor,如下所示

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM