显示语言资源文件中的占位符文本
本文关键字:占位符 文本 源文件 语言 资源 显示 | 更新日期: 2023-09-27 18:33:20
我有一个文本区域来显示描述,我的模型看起来像
[Display(Name = "CopyrightHolder_AdditionalInfo_Label", ResourceType = typeof(Resource))]
public string AdditionalInfo { get; set; }
在剃刀中,我使用这样的形式
<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>
我还计划在此文本区域显示一个占位符,该占位符应从资源文件加载有什么办法可以做同样的事情吗?
您可以像下面这样添加它:
@Html.TextAreaFor(
model => model.AdditionalInfo,
new {
@class = "form-control",
@rows = "5",
@placeholder = @Resources.Strings.YourKeyString,
@maxlength = "545"
}
)