0

I am new in MVC and ASP.NET. I am creating an application in which I want to add Employee Details like Personal, education etc

So, for education detail I created a Partial View and when user clicks on Add More link I want to add that Partial View in existing View. So, every time user click on that link I want to add one Partial View in the existing View.

Can anyone please tell me how I can achieve this. Thanks

EDIT

So by default I add Partial View like

   @{
        Html.RenderPartial("Education");
    }
    @Html.ActionLink("Add More", null, null, new { @class = "btn btn-primary" })

so on the Add More link I want to add More Partial View

Lakshraj
  • 291
  • 2
  • 18
  • Add any coding attempt you have made. If `JQuery` is part of the solution, add it as a tag to your post. I believe you will want to use `ajax` to get the partial view as `html` and append it to the view. – Ryan Wilson Sep 02 '20 at 18:31
  • @RyanWilson Edited the question – Lakshraj Sep 02 '20 at 18:36

1 Answers1

0

You can call your controller which will return the partial view using the AJAX call as follows. The resulting HTML (partial view) will be appending to the parent div.

@Ajax.ActionLink("Load More", "MorePosts", new AjaxOptions()
{
    HttpMethod = "GET",
    AllowCache = false,
    InsertionMode = InsertionMode.InsertAfter,
    UpdateTargetId = "emp-details"
})

Refer the SO link for more details How to render partial view in MVC5 via ajax call to a controller and return HTML