@Html.TextAreaFor(model => model.DESCRIPTION, 20, 50, new { htmlAttributes = new { @class = "form-control"} })
Question: The above code displays rows and cols of textarea correctly but the below ignores rows/cols and displays the default size per browser. What's wrong in below code?
The extra new
in below code was auto created by VS when creating a MVC Entity Framework controller (as documented at http://www.asp.net/mvc/overview/releases/mvc51-release-notes)
@Html.TextAreaFor(model => model.DESCRIPTION, new { htmlAttributes = new { @class = "form-control", @rows="20", @cols="50"} })
This works on MVC 5.2.2:
@Html.TextAreaFor(model => model.Caracteristicas, new { @class = "form-control", @rows = "10" })
Try using mvc5 cols and rows attribute for TextAreaFor, and also apply the CSS style for the text area.
<div class="col-md-10" id="textArea">
@Html.TextAreaFor(model => model.DESCRIPTION, 10, 100, new { htmlAttributes = new { @class = "form-control" } })
</div>
And CSS:
#textArea textarea {
max-width: 600px;}
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