views:

13

answers:

1

Hi all, in my current asp.net mvc project I'm using the built in functions for displaying resourcebased text as headers for my textboxes and stuff. In Create and Edit views this is accomplished by using the HtmlHelper LabelFor method like this:

Html.LabelFor(model => model.InternalTitle)

BUT, the default in the asp.net mvc 2 template is List views (that generates a table based on an IEnumerable<>) is the headers hardcoded like this:

<th>InternalTitle</th>

Is there a nice way to get the same result as in the Create and Edit views here aswell? I have looked at the LabelFor<> method but cannot figure of how to make that work.

Of course i could just use the Resource property that is used on my domainmodelproperty. But i think it will look even better if there was some way to use the LabelFor method or something similar.

I do not want to invent the wheel once again by implementing my own reflectionbased helper method and i think that this should be in there by default, or at least i hope so....

A: 

To get the display name of a model property you should call ExpressionHelper.GetExpressionText.

marcind