Updating PartialView mvc 4

前端 未结 4 1876
广开言路
广开言路 2020-11-30 04:40

Ey! How I could refresh a Partial View with data out of the Model? First time, when the page loads it\'s working properly, but not when I call it from the Action. The struct

4条回答
  •  感情败类
    2020-11-30 05:33

    Controller :

    public ActionResult Refresh(string ID)
        {
            DetailsViewModel vm = new DetailsViewModel();  // Model
            vm.productDetails = _product.GetproductDetails(ID); 
            /* "productDetails " is a property in "DetailsViewModel"
            "GetProductDetails" is a method in "Product" class
            "_product" is an interface of "Product" class */
    
            return PartialView("_Details", vm); // Details is a partial view
        }
    

    In yore index page you should to have refresh link :

         Refresh
    

    This Script should be also in your index page:

    
    
                                     
                  
提交回复
热议问题