ASP.NET MVC - get ViewContext from helper method

I would like to create a static helper method that I can call from a view.

Is it possible for a helper method to access the current ViewContext without having to explicitly pass the ViewContext to the method as a parameter?

Something like HttpContext.Current, except for ViewContext.

+5
source share
1 answer
public static class XTenshuns
{
    public static string MyHtmlHelper(this HtmlHelper helper)
    {
        // it right here -> helper.ViewContext
    }
}
+8
source

All Articles