当前位置:asp编程网>技术教程>Asp教程>  正文

ASP内容分页函数

2010-09-12 10:07:04   来源:本站原创    作者:佚名   浏览量:2080   收藏
<%
'==============================================
'函数名:ContentPage
'作  用:内容分页
'参  数:1、oContent ----- 文章内容
'   2、oLink  ----- 链接
'整  理:www.aspprogram.cn
'原创文章,转载请保留此信息,谢谢
'==============================================

Function ContentPage(oContent, oLink)
    Dim outStr, arrContent, NextPage, arrPage
    If InStr(oContent, "[NextPage]") <= 0 Then
        outStr = oContent
    Else
        NextPage = Request("NextPage")
        arrContent = Split(oContent, "[NextPage]")
        arrPage = UBound(arrContent) + 1
        If (NextPage = "" Or IsNull(NextPage) Or Not IsNumeric(NextPage)) Then
            NextPage = 1
        Else
            NextPage = CInt(NextPage)
        End If
        If NextPage < 1 Then
            NextPage = 1
        End If
        If NextPage > arrPage Then
            NextPage = arrPage
        End If
        outStr = arrContent(NextPage - 1)
        outStr = outStr "<br>"
        For iii = 1 To arrPage
            If iii = NextPage Then
                outStr = outStr "<font color=""red"">"&iii"</font> "
            Else
                outStr = outStr "<a href="""&oLink"NextPage="&iii""">"&iii"</a> "
            End If
        Next
    End If
    ContentPage = outStr
End Function

'=================Demo==================
Dim sStrHtml, oStrHtml
sStrHtml = "我的名字叫胡浪[NextPage]胡是古月的胡[NextPage]浪是三点水一个良字的浪[NextPage]不是一个帅哥哦[NextPage]很普通的一个人"
oStrHtml = "我的名字叫胡浪,胡是古月的胡,浪是三点水一个良字的浪,不是一个帅哥哦,很普通的一个人"
'=================Demo==================
Response.Write("------------------- 带分页 ---------------------")
Response.Write("<br>")
Response.Write(ContentPage(sStrHtml, "?"))
Response.Write("<br>")
Response.Write("------------------- 不带分页 ---------------------")
Response.Write("<br>")
Response.Write(ContentPage(oStrHtml, "?"))
%>
(鼠标移到代码上去,在代码的顶部会出现四个图标,第一个是查看源代码,第二个是复制代码,第三个是打印代码,第四个是帮助)


关于我们-广告合作-联系我们-积分规则-网站地图

Copyright(C)2013-2017版权所属asp编程网