显示名称属性与显示属性 [英] displayname attribute vs display attribute
本文介绍了显示名称属性与显示属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ASP.NET MVC中DisplayName
属性和Display
属性有什么区别?
What is difference between DisplayName
attribute and Display
attribute in ASP.NET MVC?
推荐答案
它们都给你相同的结果,但我看到的主要区别是你不能在 DisplayName<中指定
ResourceType
/code> 属性.对于 MVC 2 中的示例,您必须子类化 DisplayName
属性以通过本地化提供资源.Display
属性(MVC3 和 .NET4 中的新属性)支持将 ResourceType
重载作为开箱即用"属性.
They both give you the same results but the key difference I see is that you cannot specify a ResourceType
in DisplayName
attribute. For an example in MVC 2, you had to subclass the DisplayName
attribute to provide resource via localization. Display
attribute (new in MVC3 and .NET4) supports ResourceType
overload as an "out of the box" property.
这篇关于显示名称属性与显示属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文