繁体   English   中英

MultiLineText DataType值未在TextAreaFor中填充

[英]MultiLineText DataType Value not populating in TextAreaFor

我正在尝试对当前文本区域值实施更新。

数据类型在我的模型中设置为多行

[DataType(DataType.MultilineText)]
public string Text { get; set; }

当页面加载到textarea时,不会填充。

@Html.TextAreaFor(a => a.Text, new { @Value = Model.Text })

但是对于文本框,它确实会填充

@Html.TextBoxFor(a => a.Text, new { @Value = Model.Text })

有什么我想念的吗? 这似乎很简单。

它应该像这样工作

在此处输入图片说明

@Html.TextAreaFor(a => a.Text,  new { id = "SomeID", placeholder = "Text", Value = Model.Text})

@Html.TextAreaFor(m => m.UserName)应该足够了@Html.TextAreaFor(m => m.UserName) MVC负责从模型到文本区域填充当前值。 使用{ @Value = Model.Text }不适用于textarea,因为它不使用value属性: 如何为html <textarea>添加默认值?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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