Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access WebViewPage from custom HTML Helper

I've got a ASP.NET MVC 3 Razor Web Application.

I've got a WebViewPage extension:

public static bool Blah(this WebViewPage webViewPage)
{
   return blah && blah;
}

And i want to access this from my HtmlHelper extension:

public static MvcHtmlString BlahHelper(this HtmlHelper htmlHelper, string linkText, string actionName)
{
   // how can i get access to the WebViewPage extension method here?
}

I can of course duplicate the functionality of the WebViewPage extension if i had to, but just wondering if it's possible to access it from the HTML helper.

like image 997
RPM1984 Avatar asked Dec 28 '22 08:12

RPM1984


1 Answers

// Warning: this cast will crash
// if you are not using the Razor view engine
var wvp = (WebViewPage)htmlHelper.ViewDataContainer;
var result = wvp.Blah();
like image 99
Darin Dimitrov Avatar answered Jan 16 '23 06:01

Darin Dimitrov