Loading partial views
$ ("#result"). Load ("/home/message", function () {
Hide progress bar after loading
});
Public ActionResult message () {
Return Partialview ("View", entity);
}
The use of paging controls
Page:
< div id = "Commentlist" >
@ {Html. Renderaction ("Index", "Comment", new {id = @ Model). ProductID, page = 1}); }
</div >
Detail View
@UsingWebdiyer. WebControls. MVC; @ Model Pagedlist < Extshop. Models. T_comment >@ {foreach (var cInchModel) {< divclass ="Row"> < divclass = " title " > @ C. Title </div > < b > @ c. Username </b > & nbsp; Posted at @ (c. Createtime) < br/> @ C. Description </div > }} < br/> < div class = ' pagenav ' > @ Ajax. Pager (Model, new Pageroptions {pageindexparametername = " page "}, new Ajaxoptions {Update Targetid = " commentlist "}) </div >
Ajax method of paging, so that you can use Ajax to automatically update this section. The Updatetargetid parameter is defined as "commentlist" in ajaxoption, meaning that when Ajax loads the data, the contents of the HTML element with the ID "commentlist" are automatically updated
Or
@Html. Pager (Model,Newpageroptions{Pageindexparametername ="Idtrue, Firstpagetext = " home " Prevpagetext = Span data-mce-= "" > " prev " NextPageText = " next " Lastpagetext = " last " , Pageindexboxtype = Pageindexboxtype.textbox, pageindexboxwrapperformatstring = " Please enter the number of pages {0} " " go to "})
Background:
Create a new controller named "Commentcontroller" and modify the index operation code as follows: Public actionresult int int? Page) { ""] =2return Partialview (q);} The 1th parameter ID in the code represents the Product ID, and the 2nd parameter is the current page of the comment. As with the product list, use Mvcpager for paging.
Mvcpager.rar
Pagertest.zip
The use of partial views in MVC