| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 388 人关注过本帖
标题:asp分页请教
只看楼主 加入收藏
a7858250
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-5-22
收藏
 问题点数:0 回复次数:0 
asp分页请教
如何修改下面的代码才可以达到  每页满 2000字就自动分页的效果呢
谢谢帮忙
********************以下信息为为内容分页函数****************
Const maxPagesize=400                '设置分页字数
Function InsertPageBreak(strText)
    Dim strPagebreak,s,ss
    Dim i,IsCount,c,iCount,strTemp,Temp_String,Temp_Array
    strPagebreak="[hiweb_break]"
    s=strText
    If Len(s)<maxPagesize Then
        InsertPageBreak=s
    End If
    s=Replace(s, strPagebreak, "")
    s=Replace(s, "&nbsp;", "<&nbsp;>")
    s=Replace(s, "&gt;", "<&gt;>")
    s=Replace(s, "&lt;", "<&lt;>")
    s=Replace(s, "&quot;", "<&quot;>")
    s=Replace(s, "'", "<'>")
    If s<>"" and maxPagesize<>0 and InStr(1,s,strPagebreak)=0 then
        IsCount=True
        Temp_String=""
        For i= 1 To Len(s)
            c=Mid(s,i,1)
            If c="<" Then
                IsCount=False
            ElseIf c=">" Then
                IsCount=True
            Else
                If IsCount=True Then
                    If Abs(Asc(c))>255 Then
                        iCount=iCount+2
                    Else
                        iCount=iCount+1
                    End If
                    If iCount>=maxPagesize And i<Len(s) Then
                        strTemp=Left(s,i)
                        If CheckPagination(strTemp,"table|a|b>|i>|strong|div|span") then
                            Temp_String=Temp_String & Trim(CStr(i)) & ","
                            iCount=0
                        End If
                    End If
                End If
            End If   
        Next
        If Len(Temp_String)>1 Then Temp_String=Left(Temp_String,Len(Temp_String)-1)
        Temp_Array=Split(Temp_String,",")
        For i = UBound(Temp_Array) To LBound(Temp_Array) Step -1
            ss = Mid(s,Temp_Array(i)+1)
            If Len(ss) > 380 Then
                s=Left(s,Temp_Array(i)) & strPagebreak & ss
            Else
                s=Left(s,Temp_Array(i)) & ss
            End If
        Next
    End If
    s=Replace(s, "<&nbsp;>", "&nbsp;")
    s=Replace(s, "<&gt;>", "&gt;")
    s=Replace(s, "<&lt;>", "&lt;")
    s=Replace(s, "<&quot;>", "&quot;")
    s=Replace(s, "<'>", "'")
    InsertPageBreak=s
End Function

Function CheckPagination(strTemp,strFind)
    Dim i,n,m_ingBeginNum,m_intEndNum
    Dim m_strBegin,m_strEnd,FindArray
    strTemp=LCase(strTemp)
    strFind=LCase(strFind)
    If strTemp<>"" and strFind<>"" then
        FindArray=split(strFind,"|")
        For i = 0 to Ubound(FindArray)
            m_strBegin="<"&FindArray(i)
            m_strEnd  ="</"&FindArray(i)
            n=0
            do while instr(n+1,strTemp,m_strBegin)<>0
                n=instr(n+1,strTemp,m_strBegin)
                m_ingBeginNum=m_ingBeginNum+1
            Loop
            n=0
            do while instr(n+1,strTemp,m_strEnd)<>0
                n=instr(n+1,strTemp,m_strEnd)
                m_intEndNum=m_intEndNum+1
            Loop
            If m_intEndNum=m_ingBeginNum then
                CheckPagination=True
            Else
                CheckPagination=False
                Exit Function
            End If
        Next
    Else
        CheckPagination=False
    End If
End Function
'函数名:ContentPagination
'定义:hiwebstr      内容
'      GetStrid      内容读取的Id参数
'      GetFontColor  点击后的超连接颜色
'      MBottomPx     距底部多大(margin-bottom)
Function ContentPagination(hiwebstr,GetStrid,GetFontColor,MBottomPx)
    Dim ContentLen, maxperpage, Paginate
    Dim arrContent, strContent, i
    Dim m_strFileUrl,m_strFileExt,ArticleID
    ArticleID=Request.QueryString("ID")
    strContent = InsertPageBreak(hiwebstr)
    ContentLen = Len(strContent)
if IsNumeric(request("page"))=True then
    CurrentPage=Request.QueryString("Page")
    else
    CurrentPage=1
    end if
    If CurrentPage="" Then CurrentPage=0
    If InStr(strContent, "[hiweb_break]") <= 0 Then
        ArticleContent = "<div id=""NewsContentLabel"" class=""NewsContent"">" & strContent & "</div><div id=""Message"" class=""Message""></div>"
    Else
        arrContent = Split(strContent, "[hiweb_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
        strContent = "<div id=""NewsContentLabel"" class=""NewsContent"">"& arrContent(CurrentPage - 1)
        ArticleContent = ArticleContent & strContent
        for jjk=0 to ubound(split(LCase(ArticleContent),"<font"))
        ArticleContent = ArticleContent&"</font>"
        next
        If UserArticle = True Then
            ArticleContent = ArticleContent & "</p></div><div id=""Message"" class=""Message""></div><p align=""center""style=""margin-bottom:"&MBottomPx&"px""><b>"
        Else
            ArticleContent = ArticleContent & "</p></div><p align=""center"" style=""margin-bottom:"&MBottomPx&"px""><b>"
        End If        
        If IsURLRewrite Then
            m_strFileUrl = ArticleID & "_"
        Else
            m_strFileExt = ""
            'if instr(Request.ServerVariables("QUERY_STRING"),"&")=0 then
            'm_strFileUrl = "?" & Request.ServerVariables("QUERY_STRING") & "&Page="
            'else
            'MstrFileUrlSplit=split(Request.ServerVariables("QUERY_STRING"),"&")
            'm_strFileUrl = "?" & MstrFileUrlSplit(0)& "&Page="
             m_strFileUrl = "?" & GetStrid& "&Page="
            'end if
        End If
        If CurrentPage > 1 Then
            If IsURLRewrite And (CurrentPage-1) = 1 Then
                ArticleContent = ArticleContent & "<a href="""& ArticleID & m_strFileExt & """>上一页1</a>&nbsp;&nbsp;"
            Else
                ArticleContent = ArticleContent & "<a href="""& m_strFileUrl & CurrentPage - 1 & m_strFileExt & """><span style=""color:"&GetFontColor&""">上一页</span></a>&nbsp;&nbsp;"
            End If
        End If
        For i = 1 To Paginate
            If i = CurrentPage Then
                ArticleContent = ArticleContent & "<font color="""&GetFontColor&""">[" & CStr(i) & "]</font>&nbsp;"
            Else
                If IsURLRewrite And i = 1 Then
                    ArticleContent = ArticleContent & "<a href="""& ArticleID & m_strFileExt & """><span style=""color:"&GetFontColor&""">[" & i & "]</span></a>&nbsp;"
                Else
                    ArticleContent = ArticleContent & "<a href="""& m_strFileUrl & i & m_strFileExt & """><span style=""color:"&GetFontColor&""">[" & i & "]</span></a>&nbsp;"
                End if
            End If
        Next
        If CurrentPage < Paginate Then
            ArticleContent = ArticleContent & "&nbsp;<a href="""& m_strFileUrl & CurrentPage + 1 & m_strFileExt & """><span style=""color:"&GetFontColor&""">下一页</span></a>"
        End If
        if CStr(request("page"))=CStr(i-1) then
            ArticleContent = ArticleContent & "&nbsp;&nbsp;<font color="""&GetFontColor&""">末页</font>"
            else
            ArticleContent = ArticleContent & "&nbsp;&nbsp;<a href="""& m_strFileUrl & i-1 & """><span style=""color:"&GetFontColor&""">末页</span></a>"            
            end if   
        ArticleContent = ArticleContent & "</b></p>"
    End If
    Response.Write(ArticleContent)
End Function
搜索更多相关主题的帖子: asp 
2010-05-22 03:09
快速回复:asp分页请教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020673 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved