Is there a way to get access to the full @Url helper object inside an @helper declaration?
I want to do something like this…
@helper Button(System.Web.Mvc.ActionResult action, string text)
{
<input type="button" name="btn" value="@text" onclick="windows.location='@Url.Action(action)'" />
}
I found this question but this solution does not get you access to @Url.Action(ActionResult). Please note the specific overload that I am looking for.
So has anyone figured out a solution to this one? I could always do the extension method style for custom helpers, but I like the @helper style and I’ve already run into this problem a few times.
Thanks in advance, everybody!
Yes, by passing it as argument to the helper method.
and when you invoke the helper from some view: