There are several ways to page out in ASP. But the most widely used on NuGet is paging with pagedlist and X.PAGEDLIST.MVC. (formerly known as: PAGEDLIST.MVC, but beginning in 2014, the author renamed the Project Name "X.pagedlist.mvc"), with this plugin will be very convenient, you can try, next will tell you how to install this NuGet plugin.
ASP 5 uses X.PAGEDLIST.MVC for paging tutorials (formerly known as PAGEDLIST.MVC)
1. Tool--nuget Package Manager--NuGet package for management solution
2, search "X.pagedlist.mvc", and install, reference
3, \controllers\usercontroller.cs Background code basic usage:
using pagedlist; Public ActionResult Index (int1) { constint; var iusers = db. Users.orderby (p = p.id). Topagedlist (page, pageSize); return View (iusers);}
4, \views\user\index.cshtml Front code basic usage:
@using pagedlist@using Pagedlist.mvc Class= "Table" > xxxxxxxx xxxx </table>new {page})
5, \app_start\routeconfig.cs configuration:
Public class routeconfig{ publicstaticvoid registerroutes (routecollection routes) { routes. Ignoreroute ("{resource}.axd/{*pathInfo}"); Routes. MapRoute ( name: "Default", URL: "{controller}/{action}/{page}", new { Controller = "User", action = "Index", page = urlparameter.optional} );} }
6.:
I did not achieve the effect of the original author, because I am mvc4, and that control on the page property Ah, is to be higher version, so there is
Compiler Error Message: CS1705: Assembly "X.pagedlist.mvc, version=4.8.0.38135, culture=neutral, publickeytoken=abbb863e9397c5e1" used System.Web.WebPages, version=3.0.0.0, Culture=neutral, publickeytoken=31bf3856ad364e35 "version higher than referenced assembly" System.Web.WebPages, version=2.0.0.0, Culture=neutral, publickeytoken=31bf3856ad364e35 "version
This version of the issue or download update is better
Immediately following the appearance
Attempt to access security-critical method failed
The Final Solution is:
1 install-packagewebmatrix.data2 install-3 update-package
VS Console Install These can, right-click Add sometimes problems, it is recommended to add this.
This problem mainly exists in Mvc4 to MVC5 when the version is incompatible, report what is wrong, we go to solve, this is not the value of the programmer exist?
Paging Control X.PAGEDLIST.MVC