I am trying to render a partial view within my main view. however, I am getting the error:
The partial view ‘CompletedJobParts’ was not found or no view engine
supports the searched locations. ~/Views/Jobs/CompletedJobParts.aspx
~/Views/Jobs/CompletedJobParts.ascx
~/Views/Shared/CompletedJobParts.aspx
~/Views/Shared/CompletedJobParts.ascx
~/Views/Jobs/CompletedJobParts.cshtml
~/Views/Jobs/CompletedJobParts.vbhtml
~/Views/Shared/CompletedJobParts.cshtml
~/Views/Shared/CompletedJobParts.vbhtml
(sorry about formatting)…
the physical layout (location) of my view is
Views/MDT/Jobs/CompletedJobParts.cshtml and I’m trying to call it from a view in the same location (ie Views/MDT/Jobs/Index.cshtml). I thought it may be a routing issue so I entered:
routes.MapRoute(
"MDT",
"MDT/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
into my Global.asax.cs file, but it doesn’t seem to search there either (ie, there’s no MDT section coming up in the locations it’s searching for).
I’m using this to render within index.cshtml:
<div id="parts_div">
@{Html.RenderPartial("CompletedJobParts", Model);}
</div>
What do I need to do to get my View to find my PartialView?
TIA
Since it seems you are calling from a different structured controller, try to specify the path:
@{Html.RenderPartial("~/Views/MDT/Jobs/CompletedJobParts.cshtml", Model);}