I want to write my own custom HTML helper that extends an existing helper. E.g. I want to create to extend @Html.EditorFor
like so:
@Html.EditorFor(model => model.percent, new { data_a_sign="%", data_p_sign="s" })
Becomes:
@Html.PercentEditorFor(model => model.percent)
How would one go about writing that?
Something like this?
namespace AdminPortal.Helpers
{
public static class HtmlHelpers
{
public static MvcHtmlString PercentEditorFor<TModel>(this HtmlHelper html,
Expression<Func<TModel>> expression)
{
// Some Magic?
}
}
}
Any pointers would be greatly appreciated.