当前位置:编程学习 > asp >>

谁有空帮我改一下这段ASP代码

Private Sub ContentPagination()
  Dim ContentLen, maxperpage, Paginate
  Dim arrContent, strContent, i
  Dim m_strFileUrl,m_strFileExt
 
  strContent = ubb.UBBCode(TextContent)
  strContent = Replace(strContent, "[NextPage]", "[page_break]")
  strContent = Replace(strContent, "[Page_Break]", "[page_break]")
  ContentLen = Len(strContent)
  If InStr(strContent, "[page_break]") <= 0 Then
   If UserArticle = True Then
    strContent = Newasp.RemoveHtml(strContent)
    strContent = Left(strContent,maxstrlen)
   End If
   ArticleContent = "" & strContent & ""
  Else
   arrContent = Split(strContent, "[page_break]")

   Paginate = UBound(arrContent) + 1
   If CurrentPage = 0 Then
    CurrentPage = 1
   Else
    CurrentPage = CLng(CurrentPage)
   End If
   If CurrentPage < 1 Then CurrentPage = 1
   If CurrentPage > Paginate Then CurrentPage = Paginate
  
   If UserArticle = True Then
    If CurrentPage = 1 Then
     strContent = arrContent(CurrentPage - 1)
     strContent = Newasp.RemoveHtml(strContent)
     strContent = Left(strContent,maxstrlen)
     strContent = "" & strContent & ""
    Else
     strContent = ""
    End If
   Else
    'strContent = arrContent(CurrentPage - 1)
    strContent = ""& arrContent(CurrentPage - 1)
   End If
  
   ArticleContent = ArticleContent & strContent
   If UserArticle = True Then
    ArticleContent = ArticleContent & "</p></div><p align=""center""><b>"
   Else
    ArticleContent = ArticleContent & "</p></div><p align=""center""><b>"
   End If
   If IsURLRewrite Then
    m_strFileExt = Newasp.HtmlExtName
    m_strFileUrl = ArticleID & "_"
   Else
    m_strFileExt = ""
    m_strFileUrl = "?id=" & ArticleID & "&Page="
   End If
   If CurrentPage > 1 Then
    If IsURLRewrite And (CurrentPage-1) = 1 Then
     ArticleContent = ArticleContent & "<a href="""& ArticleID & m_strFileExt & """>上一页</a>  "
    Else
     ArticleContent = ArticleContent & "<a href="""& m_strFileUrl & CurrentPage - 1 & m_strFileExt & """>上一页</a>  "
    End If
   End If
   For i = 1 To Paginate
    If i = CurrentPage Then
     ArticleContent = ArticleContent & "<font color=""red"">[" & CStr(i) & "]</font> "
    Else
     If IsURLRewrite And i = 1 Then
      ArticleContent = ArticleContent & "<a href="""& ArticleID & m_strFileExt & """>[" & i & "]</a> "
     Else
      ArticleContent = ArticleContent & "<a href="""& m_strFileUrl & i & m_strFileExt & """>[" & i & "]</a> "
     End if
    End If
   Next
   If CurrentPage < Paginate Then
    ArticleContent = ArticleContent & " <a href="""& m_strFileUrl & CurrentPage + 1 & m_strFileExt & """>下一页</a>"
   End If
   ArticleContent = ArticleContent & "</b></p>"
  End If
End Sub

 

以上的代码  输出结果: [1]-----[n]  下一页   ---太长了

 

想修改成 输出结果

 [1]  [2] [3][4][5][6][7][8][9][10]下一页 当点[10]的时候自动变成


上一页 [11][12][13][14][15][16][17][18][19]----[N]   下一页

 

希望在以上代码修改....

追问:需然不是100%我想要`但是你回答的接近答案了!就采纳给你吧  刚才采纳一次了!不过不小心删除了
答案:Sub ContentPagination()
  Dim ContentLen, maxperpage, Paginate
  Dim arrContent, strContent, i
  Dim m_strFileUrl,m_strFileExt
'测试用的
for h=1 to 49
TextContent=TextContent&"测试页:"&h&"[NextPage]"
next

   '这句你自己还原
  'strContent = ubb.UBBCode(TextContent)
  strContent =TextContent
  strContent = Replace(strContent, "[NextPage]", "[page_break]")
  strContent = Replace(strContent, "[Page_Break]", "[page_break]")
  ContentLen = Len(strContent)
  If InStr(strContent, "[page_break]") <= 0 Then
   If UserArticle = True Then
    strContent = Newasp.RemoveHtml(strContent)
    strContent = Left(strContent,maxstrlen)
   End If
   ArticleContent = "" & strContent & ""
  Else
   arrContent = Split(strContent, "[page_break]")
   CurrentPage=request("Page")
   Paginate = UBound(arrContent) + 1
   Paginate = 49
   If CurrentPage = 0 Then
    CurrentPage = 1
   Else
    CurrentPage = CLng(CurrentPage)
   End If
   If CurrentPage < 1 Then CurrentPage = 1
   If CurrentPage > Paginate Then CurrentPage = Paginate

 

Response.Write "总页数:"&Paginate&"<br><hr>"
   If UserArticle = True Then
    If CurrentPage = 1 Then
     strContent = arrContent(CurrentPage - 1)
     strContent = Newasp.RemoveHtml(strContent)
     strContent = Left(strContent,maxstrlen)
     strContent = "" & strContent & ""
    Else
     strContent = ""
    End If
   Else
    strContent = arrContent(CurrentPage - 1)
    strContent = ""& arrContent(CurrentPage - 1)
   End If

   ArticleContent = ArticleContent & strContent
   If UserArticle = True Then
    ArticleContent = ArticleContent & "</p></div><p align=""center""><b>"
   Else
    ArticleContent = ArticleContent & "</p></div><p align=""center""><b>"
   End If
   If IsURLRewrite Then
    m_strFileExt = Newasp.HtmlExtName
    m_strFileUrl = ArticleID & "_"
   Else
    m_strFileExt = ""
    m_strFileUrl = "?id=" & ArticleID & "&Page="
   End If
'当前大页
if int(CurrentPage/10)=CurrentPage/10 then
     kk=int(CurrentPage/10)-1
else
     kk=int(CurrentPage/10)
end if

'上十页的分页代码开始
if kk>0 then
   if CurrentPage mod 10 >0 then
        if int(CurrentPage/10)=1 then   '当前页是11到20之间时
            ArticleContent = ArticleContent & " <a href=>        else      '21页以后非10的整倍数时
            ArticleContent = ArticleContent & " <a href=>        end if
   else      '当前页是10的整倍数时
            ArticleContent = ArticleContent & " <a href=>   end if
end if
'上十页的分页代码结束

   For i = 1 To 10
       '计算本页的
       j=kk*10+i
    If j = CurrentPage Then
     ArticleContent = ArticleContent & "<font color=""red"">[" & CStr(j) & "]</font> "
    Else
         If IsURLRewrite And i = 1 Then
             ArticleContent = ArticleContent & "<a href=>         Else
             ArticleContent = ArticleContent & "<a href=>         End if
    End If
    if j>=Paginate then exit for  '最后一页跟每个10的整倍数没这个不行
   Next
'下十页的分页代码开始
if Paginate-(kk+1)*10>=9 then
   if CurrentPage mod 10 >0 then   '不是10的整倍数
        if int(CurrentPage/10)=1 then   '当前页是11到20之间时
            ArticleContent = ArticleContent & " <a href=>        else         '21页以上非10的整倍数时
            ArticleContent = ArticleContent & " <a href=>        end if
   else
        if int(CurrentPage/10)=1 then   '当前页是第10页的时候
            ArticleContent = ArticleContent & " <a href=>        else                '当前页是20页起,10的整倍数时
            ArticleContent = ArticleContent & " <a href=>        end if
   end if
end if
'下十页的分页代码结束
   ArticleContent = ArticleContent & "</b></p>"
  End If
Response.Write ArticleContent&"<br>"
End Sub

希望你能看得懂

上一个:谁会ASP中的下载页面的代码?
下一个:能给我说一下ASP和C#之间的关系

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,