In a partial view I have:
@Html.Partial("Page1")
This renders my Page1.cshtml view in the right bit.
But I would like this to be replaced with something that works like the RenderBody on my _Layout
page.
@RenderBody()
In my layout file, the "@RenderBody" is filled with whatever View
is returned after clicking on an @Html.ActionLink
- so how can I emulate the same behaviour as RenderBody
in a partial view as opposed to a layout? - it is my understanding that you can't use RenderBody
on a partial view.
What I really want is so that when I click on @Html.ActionLink("Page2", "Page2", "Menu", null, null)
the section that was @Html.Partial("Page1")
becomes @Html.Partial("Page2")
why does this seem so easy on the layout page but more work on a "nested" partial view?
I tried to set my "Layout" as the index of the "Menu" page (which has a "Menu" controller too) but this didn't work:
@{
Layout = "~/Views/Menu/Index.cshtml";
}
<div class="container body-content">
@RenderBody()
</div>