开发者

Can a data annotation discover other annotations?

开发者 https://www.devze.com 2023-03-30 23:31 出处:网络
I would like to build an extended DisplayAttribute annotation that can detect if the property has the required attribute on it.And, if so and a \"* \" in front of the name to show it is required.

I would like to build an extended DisplayAttribute annotation that can detect if the property has the required attribute on it. And, if so and a "* " in front of the name to show it is required.

Is this possible? I can't seem t开发者_C百科o figure out how to discover if other attributes are present within an attribute. Even if it is possible, will the Html.Label helper recognize it? Or do I have to extend that as well?


Writing a custom Html.LabelFor will be enough. You don't need to extend the DisplayAttribute as you cannot access other attributes from within an attribute.

0

精彩评论

暂无评论...
验证码 换一张
取 消