Copy Code code as follows:
<%@ Page language= "C #"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script runat= "Server" >
</script>
<title> Untitled Page </title>
<script language= "javascript" type= "Text/javascript" >
function ShowPage (url,num,c_p)
{
var prev=0;var next=0;var Temp=0;var html= "";
if (parseint (c_p+3) >num)
{
Prev=num;
}
Else
{
Prev=parseint (c_p+3);
}
temp=10-(prev-c_p);
if (c_p-temp>0)
{
Next=c_p-temp;
}
Else
{
Next=1;
}
If the first page displayed <10, the total number of pages is greater than 10
if (c_p+3<10&&num>c_p+3)
{
For (j=1;j<=10-(c_p+3); j + +)
{
prev++;
}
}
if (c_p!=num)
{
html+= "<a href= '" +url+ "index=" + (1+c_p) + "' > Prev </a>" ";
}
for (i=prev;i>=next;i--)
{
if (i==c_p)
{
html+= "<font color=red>" +i+ "</font>";
}
Else
{
html+= "<a href= '" +url+ "index=" +i+ "' >" +i+ "</a>" ";
}
}
if (c_p!=1)
{
html+= "<a href= '" +url+ "index=" + (c_p-1) + "' > Next </a>" ";
}
document.getElementById ("PageNumber"). innerhtml=html+ "Go to <input id=\" page\ "style=\" width:33px\ "/> Page < Input type=\ "button\" value=\ "go\" onclick=\ "Funcgo" () "/>";
}
function Funcload ()
{
var num=100;
var url= "testpager.html";
var index;
index = Geturlparam ("index");
if (index==0)
{
Index=num;
}
ShowPage (Url,num,index);
}
function Geturlparam (name)
{
var reg = new RegExp ("(^|&)" + name + "= ([^&]*) (&|$)");
var r = window.location.search.substr (1). Match (REG);
if (r!=null)
{
Return parseint (unescape (r[2));
}
return 0;
}
function Funcgo ()
{
var num=100;
if (parseint (document.getElementById ("page"). Value) >0&&parseint (document.getElementById ("page"). Value) <=num)
{
window.location.href= "testpager.html?index=" +parseint (document.getElementById ("page"). value);
}
Else
{
Alert ("page number does not exist!") ");
return false;
}
}
</script>
<body onload= "funcload (0)" >
<form id= "Form1" runat= "Server" >
<div id= "PageNumber" >
</div>
</form>
</body>