/// <Summary>
/// Counterfeit open-source pages in China. The page is similar to the URL page.
/// 1 [2] [3] [4] [100]
/// Qq: Zr, some bugs not fixed
/// <Param name = "currentIndex"> current index </param>
/// <Param name = "count"> page number </param>
/// <Param name = "url"> redirected page </param>
/// <Param name = "classname"> style name </param>
/// <Returns> </returns>
Public string pagIng (int currentIndex, int count, string url, string classname)
{
Int rightNum = 11; int step = 3;
If (step <= 0 | currentIndex <= 0)
{
Return null;
}
Int LeftNum = 0; StringBuilder sb = new StringBuilder ();
If (currentIndex-step <= 1)
LeftNum = 2;
Else
{
LeftNum = currentIndex-step;
RightNum = currentIndex + (2 * step + 1)> count? Count: currentIndex + (2 * step + 1 );
If (currentIndex + step> count)
{
RightNum = count;
}
}
If (rightNum> count)
{
RightNum = count;
}
Sb = currentIndex = 1? Sb. append ("<span class =/" '"+ classname +"'/">" + 1 + "</span>"): sb. append ("<span class =/" '"+ classname +"'/"> <a name = '" + url + "= 1'> [" + 1 + "] </a> </span> ");
For (int I = LeftNum; I <rightNum; I ++)
{
Sb = I = currentIndex? Sb. append ("<span class =/" '"+ classname +"'/">" + I + "</span>"): sb. append ("<span class =/" '"+ classname +"'/"> <a name = '" + url + "=" + I + "'> [" + I + "] </a> </span> ");
}
If (count! = 1)
Sb = currentIndex = count? Sb. append ("<span class =/" '"+ classname +"'/">" + count + "</span>"): sb. append ("<span class =/" '"+ classname +"'/"> <a name = '" + url + "=" + count + "'> [" + count + "] </a> </span> ");
Return sb. ToString ();
// Response. End ();
}
In this way
Int currentIndex = Convert. ToInt32 (Request. QueryString ["pid"]);
Int count = c1.bb () % pagesize = 0? C1.bb ()/pagesize: c1.bb ()/pagesize + 1;
String str = pagIng (currentIndex, count ,"? Pid ","");
The front-end is simple.
JQUERY
$ ("A"). click (function (){
Var pid = $ (this). attr ("name ");
((This).css ("style", "cursor: hand ");
$. Get (pid, function (data, state) {$ ("# DIV1"). empty (). append (data )});