Reputation: 294
What is the best way to extend Html Helper TextboxFor? Is there a way to reuse the defautl implementation?
Upvotes: 7
Views: 920
Reputation: 3191
You can create your extension methods (in a static class), for example:
public static MvcHtmlString MyTextBoxFor<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression)
{
// call original method
MvcHtmlString result = InputExtensions.TextBoxFor(helper, expression);
// do modification to result
return result;
}
Upvotes: 4