Algorithm code of the paging navigation area

Source: Internet
Author: User

The CS page defines several protected variables for access in HTML.

 

Code
<TD id = "tbpageindex" runat = "server">
<%
// When the first page is not displayed
If (pageindex> 1)
{
%>
<A href = "javascript: setpagenavigation ('<% = pageindex-1%>');" style = "color: maroon;"> <asp: label id = "lblprev" runat = "server" text = "Prev"> </ASP: Label> </a> & nbsp;
<%
}

Int istart = 0; // The start page number displayed;
Int iend = 0; // The ending page number displayed;

If (pagecount <= 10)
{
Istart = 1;
Iend = pagecount;
}
Else if (pageindex = 1)
{
Istart = 1;
If (pagecount> 10)
Iend = istart + 9;
Else
Iend = pagecount;
}
Else if (pageindex <= 6)
{
Istart = pageindex-1;
If (pagecount-istart <9)
Iend = pagecount;
Else
Iend = istart + 9;
}
Else if (pagecount-pageindex <4)
{
If (pagecount-pageindex> 0)
Iend = pageindex + 1;
Else
Iend = pagecount;

If (iend-9 <= 0)
Istart = 1;
Else
Istart = iend-9;
}
Else
{
Istart = pageindex-5;
Iend = pageindex + 4;
}
For (INT I = istart; I <= iend; I ++)
{
If (I = pageindex)
{Response. Write ("<strong> [" + I + "] </strong> & nbsp ;");}
Else
{
%>
<A href = "javascript: setpagenavigation ('<% = I %>');" style = "color: maroon; "> <% = I %> </a> & nbsp;
<%
}
}
If (pageindex <pagecount)
{
%>
<A href = "javascript: setpagenavigation ('<% = pageindex + 1%>');" style = "color: maroon;"> <asp: label id = "lblnext" text = "Next" runat = "server"> </ASP: Label> </a> & nbsp;
<%
}
%>
<Span style = "padding-left: 20px; color: Purple;"> <% = pageindex %>/<% = pagecount %> </span>
</TD>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.