将 AspNetPager 打造成 Bootstrap 风格分页

本文发布于 7 年前,部分内容可能已经失去参考价值。

AspNetPager 官网给出了示例

即在引入 bootstrap.css 后添加以下样式:

.pagination a[disabled] { color: #777; cursor: not-allowed; background-color: #fff; border-color: #ddd; }
.pagination span.active { z-index: 2; color: #fff; cursor: default; background-color: #337ab7; border-color: #337ab7; }

给 AspNetPager 控件添加以下属性:

CssClass="pagination" LayoutType="Ul" PagingButtonLayoutType="UnorderedList" PagingButtonSpacing="0" CurrentPageButtonClass="active"

然而,当页数超过 30 时(ShowBoxThreshold 的默认值)会显示 PageIndexBox,可以使之不显示:

ShowPageIndexBox="Never"

或者添加以下样式修饰它:

.pagination input[type=text] { width: 50px !important; display: inline-block; text-align:center; }
.pagination input[type=button] { margin-top: -3px; margin-left: 5px; }

并增加属性:

PageIndexBoxClass="form-control" SubmitButtonClass="btn btn-primary"

另外,我还添加了以下属性来适应我的项目:

UrlPaging="true" AlwaysShow="True" AlwaysShowFirstLastPageNumber="true" ShowFirstLast="false" NumericButtonCount="3"
xoyozo 7 年前
转载请注明出处
云服务器 精选特惠
可能相关的内容