I am attempting to implement an Update on a current text area value.
The datatype is set for multiline in my model
[DataType(DataType.MultilineText)]
public string Text { get; set; }
When the page loads for the textarea, it does not populate.
@Html.TextAreaFor(a => a.Text, new { @Value = Model.Text })
But for a textbox it does populate
@Html.TextBoxFor(a => a.Text, new { @Value = Model.Text })
Is there something I'm missing? this seems pretty straight forward.
@Html.TextAreaFor(a => a.Text, new { id = "SomeID", placeholder = "Text", Value = Model.Text})
@Html.TextAreaFor(m => m.UserName)
should be enough - ASP MVC takes care of populate current value from model to textarea. Using { @Value = Model.Text }
doesn't apply to textarea as it does not uses value attribute: How to add default value for html <textarea>?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.