I'm in the midst of a Razor View, and I want to use things like
@Html.EditorFor(model => model.ProductId)
but the model isn't a Product, it's a composite type for this view that looks like this:
public class SomeViewModel {
public Product Product { get; set; }
public List<Irrelevant> IrrelevantList { get; set; }
}
Well, I can say
@Html.EditorFor(model => model.Product.ProductId)
but now the markup on my page says
<input type="irrelevant" id="Product_ProductId" name="Product.ProductId" />
Two problems here:
1. That's ugly.
2. The post ActionMethod takes in a Product, so the model binder doesn't work right.
I really want an HtmlHelper<Product>
So, I gin one up like so:
var ProductHtml = new HtmlHelper<User>( this.ViewContext, new ViewDataContainer2 { ViewData...