Reputation: 4216
I have an HTML helper that I need to pass an Object to. This Object is a class that has some Properties on it that I would need to access in the helper. The actual base class of this object is a generic type so I decided that I would use a Linq expression and pass it the object.
Here is the method signature:
public static MvcHtmlString PartyDetailsField<TModel, TProperty>(this HtmlHelper<TModel> helper, string controlLabelText, Expression<Func<TModel, TProperty>> expression, IEnumerable<IDetailsConfiguration> configuation, string width = "")
Here is how I use the control:
@Html.PartyDetailsField("Identifiers", m => m.Person, Model.IdentifierConfiguration, "186px")
I need the instance information from m.Person. How can I get the object instance and access the properties of the class instance from the expression? Is there a better way of doing this?
Upvotes: 1
Views: 951
Reputation: 5162
suggest reading this post http://blogs.msdn.com/b/csharpfaq/archive/2010/03/11/how-can-i-get-objects-and-property-values-from-expression-trees.aspx
Upvotes: 1