To make multi line input field, Like ASP.NET MVC I have tried the following but didn't work in ASP.NET Core MVC:
public class Post
{
[DataType(DataType.MultilineText)]
public string Body { get; set; }
}
In the view:
<input asp-for="Body" rows="40" class="form-control"/>
Any Suggestion will be highly appreciated!!
There is an open issue in ASP.NET Core tooling repo.
The suggested workaround is to use
@Html.EditorFor(m => m.Body, additionalViewData: new { htmlAttributes = new { @class = "form-control" }})
or
<textarea asp-for="Body" class="form-control"></textarea>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With