【发布时间】:2012-03-01 06:02:36
【问题描述】:
我有一个这样的 ViewModel:
public class MyViewModel
{
[Display(Name = "One_Name", ResourceType = typeof(Resources.User.Resource1))]
public string One { get; set; }
[Display(Name = "Two_Name", ResourceType = typeof(Resources.User.Resource1))]
public string Two { get; set; }
}
在第 1 页上使用,当我做这样的事情时效果很好(例如拉回资源):
@Html.LabelFor(model => model.One)
但我也想在 第 2 页上使用此 ViewModel,但我不想将属性指向不同的资源文件(例如 Resources.User.Resource2)。
我不想欺骗班级,但我愿意接受一些 OO 技巧。
问题是属性参数必须是字符串、常量、typeof 或数组表达式。
解决这个问题的最佳方法是什么?
【问题讨论】:
-
当我需要他时,@Darin Dimitrov 在哪里。 :)
标签: c# asp.net-mvc-3 razor internationalization resource-files