Refresh partial view in mvc4

Total Post:134

 4943  View(s)
Rate this:
these days i'm working on a project, based on MVC 4.
i have to requirement to refresh partial view which use to display data from database on a view.
this partial view refresh only not whole view page?

  1. Post:604

    Re: Refresh partial view in mvc4

    Hi Tanuj
    For refreshing Partial View use given line of code

    Step 1. Use script for calling Action for calling partial view

        <script type="text/javascript">
             function OpenPoupWindow{
                   $.post('@Url.Action("RefreshPartialView", "AdminPanel")', { 'parentid': "PassParameterValue"}, function (data) {

    Note: "OpenPoupWindow" funcation
          "RefreshPartialView" Action name
          "AdminPanel" controller name
          "PartialViewContainer" id of table or div etc, witch contain partial view for display data, like this

        <table id="Industry">
                 @Html.Partial("ProductsManagerPartialView", Model.ProductsListItem)

    Step 2. Action for calling partial view

         public ActionResult RefreshPartialView(string value)
               return PartialView("ProductsManagerPartialView", Model.ProductsListItem);

    Note: "ProductsManagerPartialView" partial view name
          "ProductsListItem" Properties name

    i hope this will be help full for you

      Modified On Mar-29-2018 05:31:18 AM