What I'm trying to do is create an extension method for the HtmlHelper to create a specific output and associated details like TextBoxFor<. What I want to do is specify the property from the model class as per TextBoxFor<, then an associated controller action and other parameters.
So far the signature of the method looks like:
public static MvcHtmlString Create<TModel, TProperty, TController>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, Expression<Action<TController>> action, object htmlAttributes)
where TController : Controller
where TModel : class
The issue occurs when I go to call it. In my view if I call it as per the TextBoxFor without specifying the Model type I am able to specify the lambda expression to set the property which it's for, but when I go to specify the action I am unable to.
However, when I specify the controller type Html.Create<HomeController>( ... ) I am unable to specify the model property that the control is to be created for.
I want to be able to call it like
<%= Html.Create(x => x.Title, controller => controller.action, null) %>
I've been hitting my head for a few hours now on this issue over the past day, can anyone point me in the right direction?