tags:

views:

53

answers:

1

Hi,

I have a simple form and within I'm using Html.DisplayFor() method to show some values. There is a submit button also within the form, which is triggering an update.

The question is how to "refresh" the Display method(using AJAX). The particular action method must return a ActionResult. I see the only solution in putting the display method in a partial view or is there any other option ?

+1  A: 

You can use jQuery AJAX methods fairly easily to do this. Wrap the area you want to update in a DIV and give it an ID (say "ajax_panel") and then call a jQuery function when your submit button is clicked:

$.ajax({
                url: '/YourController/ActionMethod>',
                success: function(data) {
                    $('#ajax_panel').html(data);
                }
            });

Get the ActionMethod() to return the View you want and use a partial view to render it. I found this article useful when I tried to do something similar.

Dan Diplo