DisplayAttribute ignored? (um, no.)

To make full use of unobtrusive validation, I added the necessary attributes (DisplayAttribute, validation) to the models used in an MVC application.

However, one member of a model class did not retrieve the LabelFor text from the defined resource file, and I could not find the cause for this behavior.

After staring at the relevant code for several looong minutes, it struck me: the member was defined as field, rather than a property, missing the typical { get; set; }

I wish there was an attribute [AllPublicMembersMustBeProperties] which would cause the compiler to raise in error in such cases.

Just dreaming… 😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.