0
votes

So i got a page which have a header, a navigation menu on the left(which is a partial view), and a content on the right(which is an index view). I got a problem in reloading every page's components after navigating menu.

so here's my _Layout

<body>
<div id="header">  
    <img alt="" src="../../Content/image/asd.png" />
</div>
<div id="menuBar"></div>
<div id="partial">
    @RenderBody()
    @Html.Partial("MenuPartial")           
</div>

i also got a partial view named "MenuPartial" which has list of actionlink(with updateTargetID = "partial") which will update the content of Index.cshtml

and at my homecontroller the ActionResult Index return View()

then i got a little change on _viewStart

@{
Layout = Request.IsAjaxRequest() ? null : "~/Views/Shared/_Layout.cshtml";

}

So, what i need is, everytime the actionlink got clicked, the will be updated, my partial view(it has some updated value, so it has to be updated also) and my Index view. And my current result, when i click on action link, the body got rendered, index got updated, but my partial view is gone. anyone has a solution for this?

1
That _viewstart Change Looks odd, since you may always return PartialView() to not use the Layouts...TGlatzer
I need that change so, when i click on actionlink, then my Index.cshtml updated, it render by Index.cshtml only not the whole bodyLaxus

1 Answers

0
votes

For your use Case you could perhaps wrap up the @RenderBody() into a div

<div id="content">
  @RenderBody()
</div>

Now you can update the content only

$('#content').html("New fancy content")

You can then do the same with the navigation - just make it available as Action in the controller and return PartialView()