In some complex projects, we often encounter a page, there are many modules, there is a page to load too much or interactive data such problems this time, we are likely to take into account to solve this problem (ps by using part of the page: of course, there are many solutions here only briefly this kind of program). Many of the advantages of using part of the page, such as: can ease the long wait for user data when first loaded, relieve a page js interaction leads to much lower maintainability of the code and other issues. So, how do partial pages? Here began a brief introduction:
step1: Create a page section
Then, create with other controller is the same, for example, part of the name of the page we've created for "_PartialViewTest", consistent Controller name and page name (I'm usually so named, is also more in line with the norms and MVC route) , then the parent page how to use it?
Two options: Option One, direct load; Option Two: by JS method call, and after a suitable time event, to load the data. Direct loading: @ Html.Partial ( "_ PartialViewTest") JS call: First, create a storage container of the page
loadPartival function () { $ .ajax ({ url: '@ Url.Action ( "_ PartialViewTest")', the Data: parameters you want to pass, of the type: 'POST', Success: function (the Data) { $ ( '# Panel ') .empty () the append (Data);. } }); }
This is the end! Is not it quite simply, to try it!