Is it possible to get the EditorFor method also render the label and validation for a property like the EditorForModel method does ?
Now When I use the EditorFor method for a property (for example a string), it renders only the textbox.
EDIT
Arnis I tried it out and there some problems:
The extension method should be bound on the generic HtmlHelper class. Also returning string from the helper was causing encoded html.
So I modified your code
public static MvcHtmlString EditorWithLabel<T>(this HtmlHelper<T> h,Expression<Func<T, object>> p)
{
return new MvcHtmlString(string.Format("{0}: {1}", h.LabelFor(p), h.EditorFor(p)));
}
But the main problem is it works only with if the propert is of type string.
When the property is Decimal,Int,DateTime an excetion will be thrown.
Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.