【发布时间】:2012-09-07 11:02:44
【问题描述】:
我有一个具有一些复杂属性的模型:
public class TestModel
{
public string Prop1 { get; set; }
public SubClass Prop2 { get; set; }
}
public class SubClass
{
public string Test { get; set; }
}
public class TestModelMetadata : ModelMetadataConfiguration<TestModel>
{
public TestModelMetadata ()
{
Configure(m => m.Prop1).DisplayName("is going to be displayed");
Configure(m => m.Prop2.Test).DisplayName("is NOT going to be displayed");
}
}
当我试图在视图上显示模型时:
@Html.LabelFor(m => m.Prop1)
@Html.LabelFor(m => m.Prop2.Test)
显示 Prop1 的正确标签,而 Prop2.Test 则不显示。
有人知道解决方案吗?谢谢!!!!!!
【问题讨论】:
-
感谢@Pluc。刚刚更新了问题,使其也包含视图。
标签: asp.net asp.net-mvc asp.net-mvc-4 mvcextensions