简体   繁体   中英

partial page refresh of main view from modal window

I have a main view in my MVC4 project, called Products, which displays a list of products.

I have an "Add Product" button, which pops up a modal window, rendering a View with a few fields, and a submit button to add the product.

How do I get the product list on my main view to be updated with the newly added product without a full page refresh?

I've never tried to do exactly that, but you could try the following:

  • Have your product list be a partial view
  • Have the submit button on the modal dialog do an Ajax form submission (there's lots of examples and posts explaining how to do this, if you're not familiar with it)
  • Close the modal dialog
  • Re-load the partial view

Because this is a lot of code and views, I can't provide examples of all of it, but if you have specific questions I can try to provide some.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM