简体   繁体   中英

MultiLineText DataType Value not populating in TextAreaFor

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM