Load partial view in a div MVC

后端 未结 5 1745
难免孤独
难免孤独 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:56

    Load Partial View in a div MVC 4

    Recently I want load Partal View in Div , after doing lots of R&D and It's work for me

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

    And In Partal View Action Controller Code

    public PartialViewResult ShowCategoryForm(string title)
    {
        Model model = new Model();
        model.Title = title;
        return PartialView("~/Views/ControllerName/PartalView.cshtml", model);
    }
    

提交回复
热议问题