簡體   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