This article mainly introduces the ASP. NET MVC 4 using PAGEDLIST.MVC paging implementation code, with a certain reference value, interested in small partners can refer to
There are several ways to page out in ASP. Pagedlist, Pagedlist.mvc are available on NuGet for paging.
Reference pagedlist is installed while the reference PAGEDLIST.MVC is installed.
Copy the Code code as follows:
@Html. Pagedlistpager (pagedlist.ipagedlist<sampleinfo>) viewbag.models, page = url.action ("Index", New {page, keyword = request["keyword"], datemin = request["Datemin"], Datemax = request["Datemax"]})
Search Trigger Events:
<input type= "text" id= "Datemin" class= "Input-text wdate" style= "width:60px" value= "@Request [" Datemin "]" > < Input type= "text" id= "Datemax" class= "Input-text wdate" style= "width:60px" value= "@Request [" Datemax "]" > <input Type= "text" class= "Input-text" style= "width:250px" placeholder= "Input keywords" id= "keyword" name= "" value= "@Request [" keyword "]" > <button type= "Submit" class= "btn btn-success" id= "" Name= "" onclick= "Search ()" ><i class= "Icon-search" ></i> Search </button>
<script> function Search () { var url = "? type=1"; if ($ ("#keyword"). val ()! = "") { URL + = "&keyword=" + $ ("#keyword"). Val (); if ($ ("#datemin"). val ()! = "") { URL + = "&datemin=" + $ ("#datemin"). Val (); if ($ ("#datemax"). val ()! = "") { URL + = "&datemax=" + $ ("#datemax"). Val (); Window.location.href = "/admin/sampleinfo/index" +url; } </script>
Background method:
Iqueryable<sampleinfo> models = db. Sampleinfobll.getallentities (). Where (d = = = False); if (! d.isdel String.IsNullOrEmpty (request["keyword"])) {string keyword = request["keyword"];models = models. Where (d = d.site_chinese.contains (keyword));} if (! String.IsNullOrEmpty (request["Datemin")) {int datemin = Convert.ToInt32 (request["datemin"]); models = models. Where (d = convert.todouble (d.lon_degree) >= datemin);} if (! String.IsNullOrEmpty (request["Datemax")) {int datemax = Convert.ToInt32 (request["Datemax"]); models = models. Where (d = convert.todouble (d.lat_degree) <= Datemax);} int page = 1;if (request["page"]! = null) {page = Convert.ToInt32 (request["page"]);} Viewbag.modelscount = models. Count (); Viewbag.models = Models. (d = d.sampleinfoid). Topagedlist (page, 10);
Pagination control style:
. pagination {display:inline-block; padding-left:0; margin:20px 0; border-radius:4px;}. Pagination > li {display:inline;}. Pagination > li > A,.pagination > li > Span {position:relative; float:left; padding:6px 12px; Margin-left: -1px; line-height:1.428571429; Text-decoration:none; Background-color: #ffffff; border:1px solid #dddddd;}. Pagination > Li:first-child > A,.pagination > Li:first-child > Span {margin-left:0; Border-bottom-left-radiu s:4px; border-top-left-radius:4px;}. Pagination > Li:last-child > A,.pagination > Li:last-child > Span {border-top-right-radius:4px; Border-botto m-right-radius:4px;}. Pagination > li > A:hover,.pagination > li > Span:hover,.pagination > li > A:focus,.pagination > Li & Gt Span:focus {background-color: #eeeeee;}. Pagination >. active > A,.pagination >. active > Span,.pagination >. active > A:hover,.pagination >. Active > Span:hover,.pagination >. actIve > A:focus,.pagination >. active > Span:focus {z-index:2; color: #ffffff; cursor:default; Background-color: #428bca; Border-color: #428bca;}. Pagination > Disabled > Span,.pagination >. disabled > A,.pagination >. Disabled > A:hover,.pagination >. Disabled > A:focus {color: #999999; cursor:not-allowed; Background-color: #ffffff; Border-color: #dddddd;}. Pagination-lg > li > A,.pagination-lg > li > Span {padding:10px 16px; font-size:18px;}. Pagination-lg > Li:first-child > A,.pagination-lg > Li:first-child > span {border-bottom-left-radius:6px; bo rder-top-left-radius:6px;}. Pagination-lg > Li:last-child > A,.pagination-lg > Li:last-child > span {border-top-right-radius:6px; border -bottom-right-radius:6px;}. Pagination-sm > li > A,.pagination-sm > li > Span {padding:5px 10px; font-size:12px;}. Pagination-sm > Li:first-child > A,.pagination-sm > Li:first-child > Span {border-bottom-left-radius:3px; border-top-left-radius:3px;}. Pagination-sm > Li:last-child > A,.pagination-sm > Li:last-child > span {border-top-right-radius:3px; border -bottom-right-radius:3px;}. pager {padding-left:0; margin:20px 0; text-align:center; list-style:none;}. pager:before,.pager:after {display:table; content: "";}. Pager:after {clear:both;}. pager:before,.pager:after {display:table; content: "";}. Pager:after {clear:both;}. Pager li {display:inline;}. Pager li > A,.pager li > Span {display:inline-block; padding:5px 14px; Background-color: #ffffff; border:1px Sol ID #dddddd; border-radius:15px;}. Pager li > A:hover,.pager li > A:focus {text-decoration:none; Background-color: #eeeeee;}. Pager. Next > A,.pager Next > Span {float:right;}. Pager. Previous > A,.pager. Previous > span {float:left;}. Pager. Disabled > A,.pager. Disabled > A:hover,.pager. Disabled > A:focus,.pager. Disabled > Span {color: #99 9999; Cursor:not-allowed; Background-color: #ffffff;}. Pagination-container {text-align:center;}
Pagination Style effect: