0
votes

Am trying to get a partial view to render with an AJAX call. The following ActionResult is in my base controller which is inherited by all other controllers in the solution:

    public ActionResult FileManager()
    {
        return View("_FileManagerPartial");
    }

and the folowing code is another partial that sits on the page

@Ajax.ActionLink("File Manager", "FileManager", new AjaxOptions { UpdateTargetId = "dvFilemanagerContainer" });

dvFilemanagerContainer is a div in the layout view and the partial view "_FileManagerPartial.cshtml" is in the shared views folder.

When I click the link for the ajax call, instead of loading the intended partial view it loads a duplicate of the page into the div.

Any ideas?

Edit PartialView contents its currently just the following

<div id="dvFilemanagerWrapper">
File Manager
</div>
3
can you show your complete partial view _FileManagerPartialEhsan Sajjad

3 Answers

2
votes

change your controller to

public PartialViewResult FileManager()
{
    return PartialView("_FileManagerPartial");
}
1
votes

In View add this line, so that with partial view, the master layout is not rendered, only partial view is rendered:

@{

Layout = null;

}

<div id="dvFilemanagerWrapper">
File Manager
</div>
0
votes

Problem was to do with how my RouteConfig was handling the call. Have created a new MapRoute to point it to the right place and is now working. Thanks for help guys.