开发者

Html.LabelFor does not use Name from DisplayAttribute

I have a model like this

[MetadataType(typeof(PageMetadataMetadata))]
public class PageMetadata : IPageMetadata {
    public virtual string Name { get; set; }
}

and my metadata class like this

internal class PageMetadataMetadata {
    [Display(Name = "Title", Order = 10, Prompt开发者_JS百科 = "My awesome page")]
    [Required(ErrorMessage = "Name_Required")]
    public virtual string Name { get; set; }
}

When I use this model in my view I cannot get it to use the name from my DisplayAttribute?

@Html.LabelFor(model => model.CurrentModel.Metadata.Name)


With DisplayAttribute, you have to set also the ResourceType. If you don't want to use localization try using DisplayNameAttribute.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜