簡體   English   中英

顯示語言資源文件中的占位符文本

[英]Display placeholder text from Language resource file

我有一個文本區域來顯示描述和我的模型相同的外觀

[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>

我還計划在此文本區域上顯示一個占位符,該占位符應該從資源文件加載 有沒有辦法做到這一點?

你可以像下面這樣添加它:

@Html.TextAreaFor(
    model => model.AdditionalInfo,
    new {
        @class = "form-control",
        @rows = "5",
        @placeholder = @Resources.Strings.YourKeyString,
        @maxlength = "545"
    }
)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM