Clean views with UIHints

In the web world we're often listing string-properties along with a label on our templates. Typically found on pages that represent single entities that has a predefined set of properties, like employees, stores, departments or products. Often, this results in loads of if-checking to avoid displaying a label that has no following value, which quickly kills the readability of our views. Utilizing the UIHintAttribute lets us simplify this greatly.

A big fat bonus is that the translated label on the page will be the same as what the editors see inside Episerver edit mode - giving consistency, ease of use for editors and forcing you to actually translate it properly.

Note: The property name we retrieve in the view will represent anything after the x in the DisplayFor expression, meaning that DisplayFor(x => x.CurrentPage.Address) will not work, as the propertyName will be CurrentPage.Address. Move your properties into a separate partial view, which gets x.CurrentPage as the model.

This is really just using built in functionality in ASP.NET/Razor, but it often seems forgotten, so I thought I'd throw this out there.