分页码的代码

/// <summary>
/// 根据当前的页数显示的当前页的底部分页
/// </summary>
/// <paramname="current"></param>
/// <paramname="size"></param>
/// <paramname="zong"></param>
/// <returns></returns>
public string GetPage( int current, int size, int zong, string url)
{
string urltemp = url.IndexOf( " page= " ) >= 0 ? (Regex.Replace(url, " page=([^&]*) " , " page={0} " )):(url.IndexOf( " ? " ) >= 0 ? (url + " &page={0} " ):(url + " ?page={0} " ));

int pagecount = zong % size == 0 ? (zong / size):(zong / size + 1 );
int num = current / 10 ;

System.Text.StringBuildersball
= new System.Text.StringBuilder( "" );
int xian = current / 10 + 1 ;

int before = current % 10 == 0 ? (current / 10 ):(current / 10 );
// sball.Append("index.html'>首页</a>");
sball.AppendFormat( " &nbsp;<ahref=' " + string .Format(urltemp, " 1 " ) + " '>首页</a>&nbsp; " );
for ( int i = ((before * 10 - 5 ) > 0 ? (before * 10 - 5 ):( 1 ));i <= (before * 10 == 0 ? ( 1 ):(before * 10 ));i ++ )
{


if ((before * 10 - 5 ) < 0 )
continue ;
sball.AppendFormat(
" &nbsp;<ahref=' " + string .Format(urltemp,i.ToString()) + " '>{0}</a> " ,(i + 1 ).ToString());
// sball.Append("&nbsp;<ahref='index").Append((i).ToString()).Append(".html'>").Append((i)).Append("</a>");


sball.Append(
" &nbsp; " );
}

for ( int i = (xian - 1 ) * 10 > pagecount ? (pagecount):((xian - 1 ) * 10 );i < (xian * 10 < pagecount ? (xian * 10 ):(pagecount));i ++ )
{

if (i == 0 )
// sball.Append("<ahref='index.html'>").Append((i+1)).Append("</a>");
sball.AppendFormat( " <ahref=' " + string .Format(urltemp,(i + 1 ).ToString()) + " '> " ).Append((i + 1 )).Append( " </a> " );

else
sball.Append(
" &nbsp;&nbsp;<ahref=' " + string .Format(urltemp,(i + 1 ).ToString()) + " '> " ).Append((i + 1 )).Append( " </a> " );


}
sball.Append(
" &nbsp;<ahref=' " + string .Format(urltemp,(pagecount == 1 ? ( "" ):(pagecount.ToString()))) + " '>末页</a> " );
sball.Append(
" &nbsp;&nbsp;共 " ).Append(zong.ToString()).Append( " 条&nbsp;&nbsp;当前第 " ).Append((current).ToString()).Append( " " ).Append( " " ).Append(pagecount).Append( " " ); // .Append("<br>").Append("<inputtype=textid='pagenum'value=''size="5"/>&nbsp;<inputtype=buttonvalue='GO'οnclick=document.location='index'+document.getElementById("pagenum").value+'.html'>");

return sball.ToString();
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值