I'm using MVC's DisplayFor method to show the value of a property. However, if this value is yet another Model-object, then it will include the "ID" property of that object. I don't like that, and showing the internal database ID is not nescessary in my application.
Can I (through annotations or something similar) mark this property as "not included" in the DisplayFor process?
You might not be taking advantage of what
DisplayForcan do:and let's say that
Propertyis of typeUserNow you can create a
DisplayTemplate(~/Views/Shared/DisplayTemplates/User.ascx) that is strongly typed toUserand also namedUser.ascx. And sincePropertyis aUser, MVC will bind thisobjectto thisUserDisplayTemplate.Which could look like this:
Now you can show/ hide whatever you want off of the object your passing to
DisplayFor