Load partial view in a div MVC

后端 未结 5 1744
难免孤独
难免孤独 2020-12-16 12:04

I have a button on my MVC view on click of it, it should add a partial view in a \'div\', by calling an action which takes an object as a parameter

I tried out some

5条回答
  •  醉酒成梦
    2020-12-16 12:48

    On ajax call success function append result

    ajax call=>

    url: 'controllername/methodname'
     success: function (partialviewresult)
    { 
              $('#div').append(partialviewresult);
    }
    
      // inside controller
     public ActionResult methodname()
    {
        return PartialView("~/a/a.cshtml");
    }
    

    and controller must return partialview as result

提交回复
热议问题