我正在寻找一种更简单/更干燥的方法来使用资源我的MVC 3模型。在c#中为模型上的属性设置默认资源类型
这是怎么了,现在我做(需要每个属性被告知它使用的ressource型):
public class ContactMessageModel:BaseModel
{
[Display(Name="ReplyToEmail_DisplayName", ResourceType = typeof(Res.Views_Contact))]
public string ReplyToEmail {get; set; }
[Display(Name = "ContactReason_DisplayName", ResourceType = typeof(Res.Views_Contact))]
public string ContactReason { get; set; }
可以这样做?
这是我想做到这一点(我只是想一次定义为模型的资源型):
[Display(ResourceType = typeof(Res.Views_Contact))]
public class ContactMessageModel:BaseModel
{
[Display(Name="ReplyToEmail_DisplayName")]
public string ReplyToEmail {get; set; }
[Display(Name = "ContactReason_DisplayName")]
public string ContactReason { get; set; }
你试过了吗? –
错误是:)。给我一个错误:属性'Display'在这个声明类型上是无效的。它只对'方法,属性,索引器,字段,参数'声明有效。 – AyKarsi