Reputation: 111
How to make multi line in textbox MVC. In web forms I could change it in HTML:
TextMode="MultiLine"
but how to do this in MVC textbox?
@Html.TextBox("Napisz", null, new { @class = "ostatni" })
Upvotes: 2
Views: 5367
Reputation: 218702
You can use the TextArea
helper method
@Html.TextArea("Napisz", null, new { @class = "ostatni" })
This will render a textarea, not an input text element with multi line support.
If you want to specify the custom row number and column number, you can specify that in the htmlAttributes
parameter
@Html.TextArea("Napisz", null, new { @class = "ostatni", rows=5, cols="30" })
Another thing to note is, It is not necessary to use these helper methods. These methods simply generate the htmk markup. So instead of using these helper methods, you are free to write pure markup like this
<textarea class="ostatni" cols="30" id="Napisz" name="Napisz" rows="5"></textarea>
In asp.net core, we have tag helpers and usage of which is very similar to writing pure html (it was created for the front end designers who does not need to worry about c#)
Upvotes: 2