I refer to this question.
The answer offered works really well but it doesn't seem to take the data annotation attributes for the DisplayNameAttribute into account when using the new labelfor helper.
This is the code I am using:
public static MvcHtmlString LabelFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, string prefix, Expression<Func<TModel, TProperty>> expression, IDictionary<string, object> htmlAttributes)
{
return htmlHelper.Label(String.Format("{0}.{1}", prefix, expression));
}
Is there any way around this or am I just going to have to use a normal Label helper?