How Do I Create A Multi Line Text Box In Asp.net Mvc?
How do I create a multi line text box in asp.net mvc? Probably not specific to asp.net mvc but it is what I am using. Here is what I have. <%: Html.TextBox('CommentToAdd', null,
Solution 1:
just add this attribute to property.
[DataType(DataType.MultilineText)]
publicstring CommentsToAdd{ get; set; }
Solution 2:
You want to use a text area, not a text box. Use TextAreaFor to bind it to your model, otherwise use TextArea
<%= Html.TextAreaFor(e => e.CommentsToAdd, 10, 55, null) %>
<%= Html.TextArea("CommentsToAdd", string.Empty, 10, 55, null) %>
Using razor:
@Html.TextAreaFor(e => e.CommentsToAdd, 10, 55, null)
@Html.TextArea("CommentsToAdd", string.Empty, 10, 55, null)
This will be rendered as a <textarea>
(multi-line) instead of an <input type="text" />
(single line).
Solution 3:
I think multiline textbox
in MVC is textarea
<%= Html.TextArea("Body", null, new { cols = "55", rows = "10" }) %>
or
<%= Html.TextAreaFor(x => x.Body, 10, 55, null) %>
Solution 4:
A multiline textbox is just a textarea.
Any one of these should work.
<%= Html.TextArea("Body", null, new { cols = "100", rows = "5" }) %>
<%= Html.TextArea("Body", null, 5, 100, null) %>
<%= Html.TextAreaFor(x => x.Body, 5, 100, null) %>
Post a Comment for "How Do I Create A Multi Line Text Box In Asp.net Mvc?"