I have a html helper,
if I call it like this:
Html.MyHelper("Prop1")
I can get the data of another property like this:
public static MvcHtmlString MyHelper(
this HtmlHelper html,
string prop){
var p = TypeDescriptor.GetProperties(html.ViewData.Model).Find("Prop2", false);
if (p != null) value = p.GetValue(html.ViewData.Model);
}
but if call it like this:
Html.EditorFor(x => x.Prop1);
the template contains this:
<%= Html.MyHelper(ViewData.TemplateInfo.GetFullHtmlFieldName(""), ViewData.TemplateInfo.FormattedModelValue) %>
than I can’t get the value of Prop2, anybody knows how to get it ?
You could pass the model object or create a new model object to pass in