0

I have a slightly customized version of the LabelFor() Html Helper found in the MVC2 sources. When I use it in a view I get an "Ambiguous Invocation" error - which makes perfect sense given that my also retains the signature of the original.

LabelFor<TModel, TValue>(this HtmlHelper<TModel> html, 
                         Expression<Func<TModel, TValue>> expression)

Is there a way to set up a using/import alias within the view?

Edit: Unfortunately this suggests it's not possible. It looks like creating extension methods with identical method names and signatures works in general but apparently not in aspx templates.

Community
  • 1
  • 1
nerraga
  • 614
  • 7
  • 17

1 Answers1

0

You can't do this because theres no mechanism to influence extension method resolution other than via the types of the target and the parameters involved in the resolution. In this case you will have to resort to search & replace.

An alternative would be to define your own page base type that overwrites the Html property to return your own derived HtmlHelper and base the extension off that. But that seems even hackier.

marcind
  • 52,944
  • 13
  • 125
  • 111