当前位置:网站首页>Create a custom paging control
Create a custom paging control
2022-07-28 17:20:00 【mojocube】
Doing it JAVA When the project is , Write a paging control , Thinking about C# Your friends may need , Just use C# Wrote a , There are many ways to page data on the Internet , No more repetition , Don't talk much , Here is UI End code :
/// <summary>
/// Create a custom paging control , return HTML Code
/// </summary>
/// <returns></returns>
private string CreatePager()
{
StringBuilder sb = new StringBuilder();
// The current page
int currPage = 1;
// obtain URL Page parameters
if (Request.QueryString["page"] != null)
{
currPage = int.Parse(Request.QueryString["page"]);
}
// Total number of pages
int pageCount = 18;
// Display page number
int pageNum = 5;
/ The above parameters can be dynamically adjusted , Here's the algorithm /
// The previous page
int prevPage = 1;
// The next page
int nextPage = prevPage + pageNum;
sb.Append("<ul class=\"pagination\">");
// home page
sb.Append("<li class=\"paginate_button previous\"><a href=\"Name.aspx?active=11,12&page=1\"> home page </a></li>");
int count = 0;
int currCount = 0;
for (int i = 1; i <= pageCount; i++)
{
if (i == currPage)
{
currCount = count;
}
if (i % pageNum == 0)
{
if (i < pageCount)
{
count++;
}
}
}
if (currPage > pageNum)
{
prevPage = pageNum * currCount;
sb.Append("<li class=\"paginate_button\"><a href=\"Name.aspx?active=11,12&page=" + prevPage.ToString() + "\">...</a></li>");
}
int start = pageNum * currCount + 1;
int end = pageNum * currCount + pageNum;
for (int i = start; i <= end; i++)
{
if (i <= pageCount)
{
if (i == currPage)
{
sb.Append("<li class=\"paginate_button active\"><a href=\"Name.aspx?active=11,12&page=" + i.ToString() + "\">" + i.ToString() + "</a></li>");
}
else
{
sb.Append("<li class=\"paginate_button\"><a href=\"Name.aspx?active=11,12&page=" + i.ToString() + "\">" + i.ToString() + "</a></li>");
}
}
}
if (currCount < count)
{
nextPage = pageNum * currCount + nextPage;
sb.Append("<li class=\"paginate_button\"><a href=\"Name.aspx?active=11,12&page=" + nextPage.ToString() + "\">...</a></li>");
}
// Tail page
sb.Append("<li class=\"paginate_button next\"><a href=\"Name.aspx?active=11,12&page=" + pageCount.ToString() + "\"> Tail page </a></li>");
sb.Append("</ul>");
return sb.ToString();
}边栏推荐
- Ugui learning notes (V) togglegroup makes multiple choice radio boxes
- C#遍历集合
- Goweb开发之Beego框架实战:第四节 数据库配置及连接
- Analysis of kubernetes service principle
- The practice of beego framework developed by goweb: Section 4 database configuration and connection
- Atcoder beginer contest 240 g.reporting Takahashi (classical problems of Combinatorial Mathematics)
- 2022牛客多校第二场CDE
- Re12: read these3 semantic self segmentation for abstract summary of long legal documents in low
- Realize the reset function of steering wheel UI with touch rotation and finger departure in unity
- The 16th program design competition of Dalian University of Technology (Problem Solver)
猜你喜欢

Atcoder regular contest 133 d.range XOR (digital dp+ classification discussion)

配置V530交换机步骤

Jupyter notebook win installation record

Goweb开发之Beego框架实战:第一节 Beego框架介绍

Using MVC in the UI of unity

带参数的微信小程序二维码生成

Round 1C 2022 - Code jam 2022 b.square (Mathematics, thinking)

Fine-grained Fact Verification with Kernel GA Network

mysql 最大建议行数2000w,靠谱吗?

How do we do full link grayscale on the database?
随机推荐
System clock failure of database fault tolerance
Realize the reset function of steering wheel UI with touch rotation and finger departure in unity
C # traversal set
Create a self-organizing / safe / controllable Lora network! Semtech responded for the first time to the impact of the "new regulations of the Ministry of industry and information technology"
Codeforces round 768 (Div. 2) e.paint the middle (greedy / interval relationship processing)
数据库故障容错之系统时钟故障
高速电路中电容的选型和应用——详解
一文了解 Kubernetes 中的服务发现
Pytorch Foundation: similarities and differences between torch.mul, torch.mm and torch.matmul
Vscode界面介绍
MySQL详细学习教程(建议收藏)
Kubernetes service and ingress you need to master
Unity3d shader achieves ablation effect
MySQL installation tutorial
Function接口之andThen
Ugui learning notes (IV) ugui event system overview and Usage Summary
Difference between reconnaissance aircraft and early warning aircraft
The actual combat of the beego framework of goweb development: Section III program execution process analysis
The practice of the beego framework for goweb development: Section V project construction and user registration
Codeforces round 770 (Div. 2) e. fair share