Reputation:
I have define the following on my Model class:-
[DataType(DataType.MultilineText)]
public string Description { get; set; }
On the view I have the following:-
<span class="f"> Description :- </span>
@Html.EditorFor(model => model.Description)
@Html.ValidationMessageFor(model => model.Description)
now the output will be a small text area, but it will not show all the text . so how I can control the size of the DataType.MultilineText ?
:::EDIT:::
I have added the following to the CSS file:-
.f {
font-weight:bold;
color:#000000;
}
.f textarea {
width: 850px;
height: 700px;
}
And I have defined this :-
<div >
<span class="f"> Description :- </span>
@Html.TextArea("Description")
@Html.ValidationMessageFor(model => model.Description)
</div>
But nothing actually changed regarding the multi-line display.
Upvotes: 1
Views: 5686
Reputation: 41
This worked for me, with DataType set to MultilineText in the model:
[DataType(DataType.MultilineText)]
public string Description { get; set; }
And in the View specifying the HTML attribute "rows":
@Html.EditorFor(model => model.Description, new { htmlAttributes = new { rows = "4" } })
Generates HTML like that:
<textarea ... rows="4"></textarea>
A text area with 4 rows.
Upvotes: 4
Reputation: 1039428
so how I can control the size of the DataType.MultilineText ?
You could define a class to the textarea:
@Html.TextArea("Description", new { @class = "mytextarea" })
and then in your CSS file:
.mytextarea {
width: 850px;
height: 700px;
}
Upvotes: 0