Reputation: 40
I have a method in controller like this
public PartialViewResult CabinSearch()
{
return PartialView();
}
and I have created a view to this method.
I need to access this partial view to master page
Upvotes: 1
Views: 393
Reputation: 6361
In Razor, the @Html.Partial(viewName)
helper will render the named partial view inline in the view. There are other invocations of that to pass a model object to the partial view if it is required.
If you need to invoke the controller method to perform some calculation or database access (as you imply) you can instead use @Html.Action(actionName, controllerName)
or some variant of that - where CabinSearch is the action name in your case. This will invoke the controller, which will do whatever it does (model preparation) and then render the partial view, which will then be inlined into the page.
Upvotes: 1