Refresh a partial view in MVC 4 on a button click

6523
Views
2
Answers

How do I refresh a partial view on a button click event. I need to update the data in the partial view based on the button click.

edit | flag
Mike Carpenter
Asked on: Feb 11, 2012 at 3:53AM

2 Answers

129
3
129

The best approach is to wrap the partial view in a div and refresh it using Jquery ajax call to the action which returns data to the partial view.

div id="refresh">% Html.RenderPartial("Refrehpartial")%>/div>

and the Jquery

$.ajax({
           type
: "GET",
            url
: "controller/action,
            dataType: "
html",
            success: function (resultdata) {
                $('#refresh').html(resultdata);
            }
        });
edit | flag
Gokul A
Answered on: Feb 11, 2012 at 3:57AM
183
0
183
edit | flag
maddy D
Answered on: Mar 25, 2015 at 12:45PM

Post your Answer

Search

Welcome to Ask Amoeba!
This is 100% free and interactive site for sharing professional Questions and Answers, Opensource projects, Interview questions.
Learners, beginners, Experts stop and share your knowledge and ideas!

Browse Categories

Browse Tags