我有以下代碼的表達或數組創建表達式:ASP.NET MVC4:屬性參數必須是常量表達式的typeof屬性參數類型
[Required(ErrorMessage = MessageModel.translateMessage("required")))]
[Display(Name= MessageModel.translateMessage("id"))]
public string user_id { get; set; }
我試圖使該錯誤消息動態但是,當編譯:
"An attribute argument must be a constant expression , typeof expression or array creation expression of an attribute parameter type."
針對此問題的任何解決方案,我得到的錯誤?
看看這個問題:http://stackoverflow.com/questions/3814866/dynamic-parameters-for-attributes – 2013-02-21 09:51:52
這導致發貼由Eric Lippert:http://blogs.msdn.com/b/ericlippert/ archive/2009/02/02/properties-vs-attributes.aspx – 2013-02-21 09:53:31
[C#Dynamic Attribute Arguments](http://stackoverflow.com/questions/1093466/c-sharp-dynamic-attribute-arguments) – jgauffin 2013-02-21 10:00:24