Dynamically load Partial Views

后端 未结 6 1003
醉话见心
醉话见心 2020-12-14 16:58

How can i dynamically load a Partial View?

I mean I have this view, lets say ListProducts, there I select some dropdownlists with products, etc, and wit

6条回答
  •  悲&欢浪女
    2020-12-14 17:46

    You can use ajax to call action an then just insert html string using jQuery to the page where you want it to appear:

    Server-side:

    Render partial view to string Renders partial view on server to html string, useful when you need to add partial view to ASP.NET MVC page via AJAX.

    Client-side:

    $('#yourDdl').change(function()
    {
      $.get('/InsertPartialViewUsingAjax', function (data) 
      {
         $('#container').html(data);
      });
    });
    

提交回复
热议问题