Reputation: 171
I have a partial view located in ~/Views/Partials/menubar.cshtml
.
In my ~/Views folder i have a master page Called Menubar.cshtml
<- this masterpage calls the
@{ Html.RenderPartial("menubar") }
but it says:
"Cannot resolve partial view "menubar"
How can i fix this? I've tried the direct path like
@{ Html.RenderPartial("~/Views/Partials/menubar.cshtml") }
still the same issue.
It has to be said that im using Umbraco 4.11 and Visual studio 2012 with resharper.
Here is the code for my masterpage (it has another masterpage):
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = "Master.cshtml";
}
<div id="header">
<a href="/"><img src="/images/logo.gif" width="259" height="65" /></a>
<div id="sitedescription">
<h1>Runway</h1>
<h1>Off to a great start</h1>
</div>
@{ Html.RenderPartial("Menubar"); }
</div>
@RenderBody()
This is the code for my view, simplified just to get it working at first, there will be added some logic, otherwise the view would not make sense to have:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
<div id="mainmenu">
<ul id="topNavigation">
<li class="home current"><a href="/">Home</a></li>
<li><a class="navigation" href="/"><span>Newz</span></a></li>
<li><a class="navigation" href="/"><span>Programmering</span></a></li>
<li><a class="navigation" href="/"><span>Support</span></a></li>
<li><a class="navigation" href="/"><span>Repair</span></a></li>
</ul>
</div>
<div class="mainmenucorner"> </div>
Here is an image of the structure in visual studio:
Can anyone tell me what i'm missing here, have spend hours on this now.
EDIT I've found out that id i locate it under /Views/Shared it'll find it automatically.. It just seems that umbraco posts this page as the main page then - any thougts?
Upvotes: 2
Views: 4690
Reputation: 71
Try renaming the partial to _menuBar.cshtml, and render it using this:
@Html.Partial("_menuBar")
It works for me.
Upvotes: 1