Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 显示名称的数据批注未以Razor格式呈现_Asp.net Mvc_Razor_Data Annotations - Fatal编程技术网

Asp.net mvc 显示名称的数据批注未以Razor格式呈现

Asp.net mvc 显示名称的数据批注未以Razor格式呈现,asp.net-mvc,razor,data-annotations,Asp.net Mvc,Razor,Data Annotations,我试图使用数据注释在模型类中指定一个显示名称,但视图没有显示该名称。它默认为属性名并忽略数据注释 在我的模型中: public interface IFeedbackLogMetadata { [Display(Name="Description")] string FeedbackDescription { get; set; } } public partial class FeedbackLog : PersistantEntity, IFeedbackLo

我试图使用数据注释在模型类中指定一个显示名称,但视图没有显示该名称。它默认为属性名并忽略数据注释

在我的模型中:

public interface IFeedbackLogMetadata
{
        [Display(Name="Description")]
        string FeedbackDescription { get; set; }
}
public partial class FeedbackLog : PersistantEntity, IFeedbackLogMetadata
{
//..other stuff
}
我也尝试过:

[DisplayName("Description")]
string FeedbackDescription { get; set; }
在我看来,我尝试过:

@Html.LabelFor(model => model.FeedbackDescription, htmlAttributes: new {@class = "control-label col-md-2"})
<label class="control-label col-md-2">@Html.DisplayNameFor(d => d.FeedbackDescription)</label>
@Html.LabelFor(model=>model.FeedbackDescription,htmlAttributes:new{@class=“control label col-md-2”})
@DisplayNameFor(d=>d.FeedbackDescription)
标签显示“反馈说明”。它应该是“描述”。为什么忽略显示名称数据批注?

/Headsmack/

我需要用接口的MetadataType来修饰分部类。否则,视图将从EF生成的类中提取,该类没有数据注释

[MetadataType(typeof(IFeedbackLogMetadata))]
public partial class FeedbackLog : PersistantEntity, IFeedbackLogMetadata
{
//...other stuff
}

确保没有覆盖它的字符串的
视图/共享/显示模板
。@SteveGreene-我没有。