Tan*_*jel 7 html asp.net asp.net-core-mvc asp.net-core
为了制作多行输入字段,像ASP.NET MVC一样,我尝试了以下操作,但在ASP.NET Core MVC中不起作用:
public class Post
{
[DataType(DataType.MultilineText)]
public string Body { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在视图中:
<input asp-for="Body" rows="40" class="form-control"/>
Run Code Online (Sandbox Code Playgroud)
任何建议将不胜感激!
ASP.NET Core工具存储库中有一个未解决的问题。
建议的解决方法是使用
@Html.EditorFor(m => m.Body, additionalViewData: new { htmlAttributes = new { @class = "form-control" }})
Run Code Online (Sandbox Code Playgroud)
要么
<textarea asp-for="Body" class="form-control"></textarea>
Run Code Online (Sandbox Code Playgroud)
还可以选择使用<textarea>
-tag
它看起来像这样:
<div class="form-group">
<label asp-for="Body">Opmerkingen</label>
<textarea asp-for="Body" class="form-control" text-wrap:normal" type="text" placeholder="Please add your experience here"></textarea>
<span asp-validation-for="Body" class="text-danger"></span>
</div>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10341 次 |
最近记录: |