Ok im very new to ASP.NET 4.5 (giving PHP a break) and stuck with rendering a label.
I have a ViewModel that defines the necessary Models :
public class TransactionsViewModel {
public IEnumerable<Transaction> Transactions { get; set; }
public IEnumerable<Area> Areas { get; set; }
public IEnumerable<Mistake> Mistakes { get; set; }
...
}
Transaction is just another model with simple properties, now i want to display a label for one of the Transaction properties.
My View has the strong type TransactionsViewModel
@model AuditSystem.ViewModels.TransactionsViewModel
This means that the HTMLHelper has type of < TransactionsViewModel> when overriding.
The method prototyope im trying to create is:
public static MvcHtmlString LabelFor<TModel, TClass, TValue>(
this HtmlHelper<TModel> helper,
IEnumerable<TClass> model,
Expression<Func<TClass, TValue>> expression,
object htmlAttributes
)
Where < TModel> is TransactionsViewModel (strong typed) and < TClass> is (Transaction)
This causes a problem when trying to call helper.LabelFor since that expectes an expression of Expression>, but i need to pass Func.
I tried to reconstruct an expression with the valid types, but get stuck on the call to the html.labelfor and typecasting wont work.