Tuesday, August 10, 2010

Class MetadataType and property DisplayName

Target : No specific target but I used it when I was working in MVC Project.

Today's issue is not a big deal and did not take any time to resolve ,but I think that it will help too much.
In view I was using html.labelfor and I was binding to GuestResponse model class.

The problem was that the displayed text for the label is the property name and I want another friendly name.

The picture below will display a good details of using a MetadataType attribute of GuestResponse class. This attribute specifies the metadata class to associate with a data model class 'GuestResponse_Metadata' in this class I added a DisplayName attribute.

Why do not I use the DisplayName attribute directly?

My project was complicated more that the sample I am talking about. Data layer was generated by a generation tool and any change will be overriden when regenerating for any reason.

I hope it helps.

1 comment:

  1. Thanks for this informative post,real estate software eliminates the hassles, leaving you with less worry and improved business.

    ReplyDelete