我有一个文本区域来显示描述,我的模型看起来像
[Display(Name = "CopyrightHolder_AdditionalInfo_Label", ResourceType = typeof(Resource))]
public string AdditionalInfo { get; set; }
在Razor中,我使用的是这样的表格
<div class="form-group">
@Html.LabelFor(model => model.AdditionalInfo)
@Html.TextAreaFor(model => model.AdditionalInfo, new { @class = "form-control", @rows = "5", @placeholder = "i wnat to load from resource file this text", @maxlength = "545" })
@Html.ValidationMessageFor(model => model.AdditionalInfo)
</div>
我还计划在此文本区域显示一个占位符,该占位符应从资源文件加载 有没有办法做同样的事情?
答案 0 :(得分:1)
你可以像下面这样添加:
@Html.TextAreaFor(
model => model.AdditionalInfo,
new {
@class = "form-control",
@rows = "5",
@placeholder = @Resources.Strings.YourKeyString,
@maxlength = "545"
}
)