濮阳杆衣贸易有限公司

主頁 > 知識庫 > C#頁碼導(dǎo)航顯示及算法實現(xiàn)代碼

C#頁碼導(dǎo)航顯示及算法實現(xiàn)代碼

熱門標(biāo)簽:保山電話外呼管理系統(tǒng)怎么用 朝陽市地圖標(biāo)注 蘇州銷售外呼系統(tǒng)預(yù)算 東莞語音電銷機器人排名 電話機器人廣告話術(shù) 太原外呼電銷機器人費用 使用智能電話機器人違法嗎 外呼系統(tǒng)用員工身份證 淘寶地圖標(biāo)注如何做
頁碼導(dǎo)航,先看顯示效果:

算法要求
1、頁數(shù)小于等于1時不顯示;
2、頁數(shù)大于10時,自動縮短。
具體代碼如下:
復(fù)制代碼 代碼如下:

/// summary>
/// 獲取分頁導(dǎo)航
/// /summary>
/// param name="intPageIndex">頁碼/param>
/// param name="intPageCount">頁數(shù)/param>
/// param name="strUrl">鏈接/param>
/// returns>HTML代碼/returns>
private string GePageNavgation(int intPageIndex, int intPageCount, string strUrl)
{
StringBuilder sb = new StringBuilder("div class=\"div_pagenavgation\">");
if (intPageCount > 1)
{
//頁碼顯示
if (intPageIndex == 1)
{
sb.Append("span class=\"disabled\"> 上一頁/span>");
}
else if (intPageIndex > 1)
{
sb.Append("a href=\"" + strUrl + (intPageIndex - 1).ToString() + "\"> 上一頁/a>");
}
bool Dot1 = false, Dot2 = false;
for (int i = 1; i = intPageCount; i++)
{
if (i == intPageIndex)
{
sb.Append("span class=\"current\">" + intPageIndex.ToString() + "/span>");
continue;
}
if (i = 3)
{
sb.Append("a href=\"" + strUrl + i.ToString() + "\">" + i.ToString() + "/a>");
continue;
}
if (intPageIndex > 7)
{
if (!Dot1)
{
sb.Append("span class=\"dotted\">.../span>");
Dot1 = true;
}
}
if (i == intPageIndex - 3)
{
sb.Append("a href=\"" + strUrl + i.ToString() + "\">" + i.ToString() + "/a>");
continue;
}
if (i == intPageIndex - 2)
{
sb.Append("a href=\"" + strUrl + i.ToString() + "\">" + i.ToString() + "/a>");
continue;
}
if (i == intPageIndex - 1)
{
sb.Append("a href=\"" + strUrl + i.ToString() + "\">" + i.ToString() + "/a>");
continue;
}
if (i == intPageIndex + 1)
{
sb.Append("a href=\"" + strUrl + i.ToString() + "\">" + i.ToString() + "/a>");
continue;
}
if (i == intPageIndex + 2)
{
sb.Append("a href=\"" + strUrl + i.ToString() + "\">" + i.ToString() + "/a>");
continue;
}
if (i == intPageIndex + 3)
{
sb.Append("a href=\"" + strUrl + i.ToString() + "\">" + i.ToString() + "/a>");
continue;
}
if ((intPageCount - intPageIndex) > 6 i > intPageIndex + 3)
{
if (!Dot2)
{
sb.Append("span class=\"dotted\">.../span>");
Dot2 = true;
}
}
if (i > intPageCount - 3)
{
sb.Append("a href=\"" + strUrl + i.ToString() + "\">" + i.ToString() + "/a>");
continue;
}
}
if (intPageIndex == intPageCount)
{
sb.Append("span class=\"disabled\">下一頁 >/span>");
}
else if (intPageIndex + 1 = intPageCount)
{
sb.Append("a href=\"" + strUrl + (intPageIndex + 1).ToString() + "\">下一頁 >/a>");
}
}
sb.Append("/div>");
return sb.ToString();
}

CSS樣式:
復(fù)制代碼 代碼如下:

.div_pagenavgation{
margin-top:5px;
line-height:20px;
float:right;
}
.div_pagenavgation a{
float:left;
text-decoration:none;
color:#06F;
margin-left:5px;
padding-left:5px;
padding-right:5px;
height:20px;
text-align:center;
display:block;
border:1px #CCC solid;
}
.div_pagenavgation .dotted{
float:left;
}
.div_pagenavgation .current{
float:left;
margin-left:5px;
padding-left:5px;
padding-right:5px;
height:20px;
text-align:center;
display:block;
border:1px #CCC solid ;
background-color:#0080C0;
color:#FFF;
}
.div_pagenavgation .disabled{
float:left;
margin-left:5px;
padding-left:5px;
padding-right:5px;
height:20px;
text-align:center;
display:block;
border:1px #CCC solid;
color:#CCC;
}

產(chǎn)生的HTML如下:
復(fù)制代碼 代碼如下:

div class="div_pagenavgation">
a href="?m=logpage=11"> 上一頁/a>
a href="?m=logpage=1">1/a>
a href="?m=logpage=2">2/a>
a href="?m=logpage=3">3/a>
span class="dotted">.../span>
a href="?m=logpage=9">9/a>
a href="?m=logpage=10">10/a>
a href="?m=logpage=11">11/a>
span class="current">12/span>
a href="?m=logpage=13">13/a>
a href="?m=logpage=14">14/a>
a href="?m=logpage=15">15/a>
span class="dotted">.../span>
a href="?m=logpage=27">27/a>
a href="?m=logpage=28">28/a>
a href="?m=logpage=29">29/a>
a href="?m=logpage=13">下一頁 >/a>
/div>

說明:很久前趕工完成,基本能夠?qū)崿F(xiàn)要求,沒有經(jīng)過仔細(xì)優(yōu)化,誰優(yōu)化了再回復(fù)看看!
您可能感興趣的文章:
  • c# TreeView添加右鍵快鍵菜單有兩種方法
  • 基于C#實現(xiàn)的仿windows左側(cè)伸縮菜單效果
  • C#實現(xiàn)Winform動態(tài)添加菜單的方法
  • C#自定義控件添加右鍵菜單的方法
  • 使用c#開發(fā)公眾平臺自定義菜單功能
  • asp.net(C#)生成無限級別菜單
  • WPF實現(xiàn)半圓形導(dǎo)航菜單

標(biāo)簽:潛江 綏化 洛陽 阿里 運城 呼倫貝爾 克拉瑪依 西藏

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《C#頁碼導(dǎo)航顯示及算法實現(xiàn)代碼》,本文關(guān)鍵詞  頁碼,導(dǎo)航,顯示,及,算法,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《C#頁碼導(dǎo)航顯示及算法實現(xiàn)代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于C#頁碼導(dǎo)航顯示及算法實現(xiàn)代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    九寨沟县| 嵊州市| 绥阳县| 大同县| 武强县| 平定县| 孟连| 沙田区| 兴安县| 罗田县| 青田县| 融水| 阳新县| 抚远县| 六枝特区| 黎川县| 芜湖县| 深泽县| 昭觉县| 陵水| 东海县| 武城县| 济宁市| 岗巴县| 禄劝| 三江| 博乐市| 津南区| 英吉沙县| 尚义县| 务川| 保亭| 普兰县| 高州市| 巨野县| 沈阳市| 新化县| 阿克苏市| 襄垣县| 凤城市| 大庆市|