[英]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. 当页面加载到textarea时,不会填充。
@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. @Html.TextAreaFor(m => m.UserName)
应该足够了@Html.TextAreaFor(m => m.UserName)
MVC负责从模型到文本区域填充当前值。 Using { @Value = Model.Text }
doesn't apply to textarea as it does not uses value attribute: How to add default value for html <textarea>? 使用
{ @Value = Model.Text }
不适用于textarea,因为它不使用value属性: 如何为html <textarea>添加默认值?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.