Updating PartialView mvc 4

The Solution to Updating PartialView mvc 4 is

So, say you have your View with PartialView, which have to be updated by button click:

<div class="target">
    @{ Html.RenderAction("UpdatePoints");}

<input class="button" value="update" />

There are some ways to do it. For example you may use jQuery:

<script type="text/javascript">
        $('.button').on("click", function(){        
            $.post('@Url.Action("PostActionToUpdatePoints", "Home")').always(function(){

PostActionToUpdatePoints is your Action with [HttpPost] attribute, which you use to update points

If you use logic in your action UpdatePoints() to update points, maybe you forgot to add [HttpPost] attribute to it:

public ActionResult UpdatePoints()
    ViewBag.points =  _Repository.Points;
    return PartialView("UpdatePoints");

~ Answered on 2013-08-15 15:58:17

Most Viewed Questions: