Reputation: 44605
I am working with mvc 4 and have created a custom HtmlHelper.
Is it possible from within that helper, to access the view that is calling the helper? I want to use properties that I have on the base view within my helper method.
Upvotes: 0
Views: 115
Reputation: 4073
Yes, you can :)
public static void MyExtension(this HtmlHelper html)
{
var view = html.ViewDataContainer;
// accessing view properties
var viewModel = view.Model;
var viewAjax = view.Ajax;
// etc
}
Upvotes: 2