Here is my css:
.editor-field textarea { width : 400; height : 100px; }
Here is the markup from my view:
<div class="editor-field"> @Html.EditorFor(model => model.Visit.BehavioralObservations) @Html.ValidationMessageFor(model => model.Visit.BehavioralObservations) </div>
And here is the annotation of my model showing the MultilineText attribute:
[DisplayName("Behavioral Observations")] [DataType(DataType.MultilineText)] public string BehavioralObservations { get; set; }
Why can't I set the width of this textarea? I can adjust the height in my CSS and it looks correct (verified with Chrome Developer tools) but the width doesn't change. Chrome says the width is an invalid property value and has a strike-through applied to the property along with a yellow triangle displayed adjacent to the property.
FYI, this is not limited to Chrome. IE8 has the same issue.
Thoughts? How do I fix this? Thanks!
The size of a text area is specified by the cols and rows attributes (or with CSS). The name attribute is needed to reference the form data after the form is submitted (if you omit the name attribute, no data from the text area will be submitted). The id attribute is needed to associate the text area with a label.
The cols attribute specifies the visible width of a text area. Tip: The size of a text area can also be set by the CSS height and width properties.
Try textarea {max-width:95%;} - it will always fit your display. Show activity on this post. I set the number of columns to slightly greater that the width of the div on a large screen and as the screen gets smaller it acts responsive to the screen size.
try to use TextAreaFor
helper method and set cols
and rows
html property
Sample
@Html.TextAreaFor(model=>model.MyMultilineText, new {rows="6", cols="10"})
I Hope this help. Regards.
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