[RESOLVED]Partial view

How do display a view on the same page on a button click? I do not want to redirect to a different page.

After I click the submit button i want to display a view below the existing view.

Do you have to display the data in the view when you click the submit button?

If you are not triggering the controller methods, then you can load the view and hide. When you click submit button, you can show the view using div.

Yes I have to display data. Can you also give me an example of your suggestion?

$('#buttonId').click( function() {
    $.ajax({
        type: 'POST',
        url: '@Url.Content("~/ControllerName/ActionName")',
        data: objectToPass,
        success: function (data) {
           $('#divid').innerHtml = data;
        }
    });
}

Hi preetahb,

Thanks for your post.

preetahb

After I click the submit button i want to display a view below the existing view.

Based on my understanding ,I suggest that you try to render the partial view in the different view.

please check this:

#Partial View in ASP.NET MVC 4

http://www.codeproject.com/Tips/617361/Partial-View-in-ASP-NET-MVC

Hope this can be helpful.

Best Regards,

Eileen

Leave a Reply