[100]asp添加分页符代码

如何给文件添加分页符代码?例如添加分页符“||”可以强制分页!不是自动分页!下面是自动分页代码!<%Functionmaindimrs,sql,i,id,PageCoun... 如何给文件添加分页符代码?例如添加分页符“||”可以强制分页!不是自动分页!下面是自动分页代码!
<%Function main
dim rs,sql,i,id,PageCount,Page,PageOut,PageIn,PageSize,content,classid,RepCount,gm,viphy,nid,read,readtime

PageSize=1200

id=Request.QueryString("id")
if id="" then id=0
if not isnumeric(id) then id=0
id=clng(id)

Page = Request("page") '当前页数
If Page = "" Then Page = 1
If Not IsNumeric(Page) Then Page = 1
Page = CLng(Page)
If Page < 1 Then Page = 1

if xy<>"Null" then

Set Rs = Server.CreateObject("Adodb.Recordset")

Sql = "select vip,id from wap545600comcn_user where xy='"&md5(xy) & md5(strReverse(xy))&"'"
Rs.Open Sql,conn,1,1

if not (rs.bof and rs.eof) then
viphy=rs("vip")
nid=rs("id")
end if
Rs.close

Sql = "select id from wap545600comcn_goumai where ext=2 and listid="&id&" and nid="&nid&""
Rs.Open Sql,conn,1,1
if not (rs.bof and rs.eof) then
gm=1
else
gm=0
end if
Rs.close

set rs=nothing
else
viphy=0
gm=0
end if

conn.execute("update wap545600comcn_view_list set ReadCount=ReadCount+1 where id="&id&"")

Set Rs = Server.CreateObject("Adodb.Recordset")

Sql = "select name,classid,Urls,zuozhe,laiyuan,RepCount,ReadCount,[WriteTime],[readtime],tuijian,vip,zf,viphy,vipgm from wap545600comcn_view_list where id="&id
Rs.Open Sql,conn,1,1
if not (rs.bof and rs.eof) then

readtime=rs("readtime")

Dim path,FsoObj,tempfileOBJ,txt
Path = server.mappath(Request.ServerVariables("SCRIPT_NAME"))
Path=left(Path,instrrev(Path,"\" ) - 1 )
path=Path & "/" & RS("urls")

Set FsoObj=Server.CreateObject("Scripting.FileSystemObject")
IF FSOObj.FileExists(path) = True then
Set tempfileOBJ = FsoObj.OpenTextFile(path, 1, 0, 0 )
While NOT tempfileOBJ.AtEndOfStream
txt=txt & tempfileOBJ.ReadLine & vbNewLine
Wend
Set tempfileOBJ=Nothing
end if
Set FsoObj=Nothing
if len(txt)>2 then txt=trim(left(txt,len(txt)-2))

if viphy=1 then
if rs("vipgm")=1 then
if gm=1 then
read=true
else
read=false
end if

else
read=true
end if
elseif rs("viphy")=1 then
read=false
elseif rs("vip")=1 then
if gm=1 or rs("zf")=0 then
read=true
else
read=false
end if
else
read=true

end if

RepCount=rs("RepCount")
classid=rs("classid")
content=txt
if Request.QueryString("act")<>1 then

end if

%>
最好能给个代码,因为我基本不懂asp!你也可以当作是对自己的训练,何乐而不为呢?我会加分!
展开
 我来答
livell
2010-12-05 · TA获得超过352个赞
知道小有建树答主
回答量:164
采纳率:0%
帮助的人:97.4万
展开全部
给你两个函数,不同的风格

'-----------------------------------------------
'函数名:PageTools
'作 者:李蔚
'作 用:显示分页信息,如“上一此悔页 下一页”等
'参 数:nRowCount ----总行数
' nRow ----每页行数
' nPage -----当前页数
' strPageCookieName ----存储每页行数的Cookies键值(如blShort为False,则赋值无效)
' strUnit ----查询结果的计数单位,默认值森慎正是“条记录”
' strFontColor ----文字颜色
' blShort ----是否自定义每页行数
'如需使用请不要删除以上信息,谢谢
'------------------------------------------------
Function PageTools(nRowCount,nRow,nPage,byval strPageCookieName,strUnit,strFontColor,blShort)
dim strCss,strTemp,nPageCount,strUrl,i
dim FirstPageTag,LastPageTag,PrePageTag,NextPageTag,Pre_PageTag,Next_PageTag
'总页数
if nRowCount > 0 then
nPageCount = PageTotal(nRowCount,nRow)
else
nPageCount = 0
end if
'翻页时调用的url
strUrl = request.ServerVariables("url") & "?" & TransParam()
'跳至首页样式
FirstPageTag = "<font face=webdings>9</font>" '|<<
'跳至末页样式
LastPageTag = "<font face=webdings>:</font>" '>>|
'跳至前10页样式
PrePageTag = "<font face=webdings>7</font>" '<<
'跳至后10页样式
NextPageTag = "<font face=webdings>8</font>" '>>
'跳至上一页样式
Pre_PageTag = "<font face=webdings>3</font>" '<
'跳至下一页样式
Next_PageTag = "<font face=webdings>4</font>" '>

if strUnit = "" then strUnit = "条记录"
if strFontColor <> "" then strCss = " style='color:" & strFontColor & "' "

strTemp = "<table><tr><td valign=""bottom""" & strCss & ">"
if nRowCount > 0 then
strTemp = strTemp & "共有<b>" & nRowCount & "</b>" & strUnit & " "
strTemp = strTemp & "共<b>" & nPageCount & "</b>页 "
end if
if nPage > 1 then
strTemp = strTemp & "<a hRef='" & strUrl & "Page=1' title='首页'" & strCss & ">" & FirstPageTag & "</a> "
if nPage >= 10 then strTemp = strTemp & "<a hRef='" & strUrl & "Page=" & CStr(nPage - 10) & "' title='上十页'" & strCss & ">" & PrePageTag & "</a> "
strTemp = strTemp & "<a hRef='" & strUrl & "Page=" & CStr(nPage - 1) & "' title='上一页'" & strCss & ">" & Pre_PageTag & "</a>孝念 "
else
strTemp = strTemp & FirstPageTag & " " & Pre_PageTag & " "
end if
strTemp = strTemp & "第<b>" & nPage & "</b>页 "
if nPage < nPageCount or nRowCount = 0 then
strTemp = strTemp & "<a hRef='" & strUrl & "Page=" & CStr(nPage + 1) & "' title='下一页'" & strCss & ">" & Next_PageTag & "</a> "
if nPageCount - nPage >= 10 then strTemp = strTemp & "<a hRef='" & strUrl & "Page=" & CStr(nPage + 10) & "' title='下十页'" & strCss & ">" & NextPageTag & "</a> "
strTemp = strTemp & "<a hRef='" & strUrl & "Page=" & nPageCount & "' title='第" & nPageCount & "页'" & strCss & ">" & LastPageTag & "</a> "
else
strTemp = strTemp & Next_PageTag & " " & LastPageTag & " "
end if
if nRowCount > 0 then
strTemp = strTemp & "转到:<SELECT name='page' onchange=""javascript:window.location='" & strUrl & "page=" & "'+this.options[this.selectedIndex].value;"">"
for i = 1 to nPageCount
strTemp = strTemp & "<option value='" & i & "'"
if nPage = cInt(i) then strTemp = strTemp & " selected "
strTemp = strTemp & ">第" & i & "页</option>"
next
strTemp = strTemp & "</SELECT> "
end if

if not blShort then
strTemp = strTemp & "每页显示 <input type=text name=PageRow size=2 value=" & nRow & "> " & strUnit & " "
strTemp = strTemp & "<input type=button value=定制 class='buttonface' onClick=""javascript:setRow(PageRow.value);location='" & strUrl & "page=1';"">"
strTemp = strTemp & "<script language=javascript>"
strTemp = strTemp & "function setRow(nRow){"
strTemp = strTemp & "var dNowDate = new Date();"
strTemp = strTemp & "var nYear = dNowDate.getYear() + 1;"
strTemp = strTemp & "dNowDate.setYear(nYear);"
strTemp = strTemp & "document.cookie = '" & strPageCookieName & "=' + nRow + '; expires=' + dNowDate.toGMTString();"
strTemp = strTemp & "}</script>"
end if
strTemp = strTemp & "</td></tr></table>"
PageTools = strTemp
end Function

Function longPageTools(nRowCount,nRow,nPage,byval strPageCookieName,strUnit,strFontColor,blShort)
dim strCss,strTemp,nPageCount,strUrl,i,j,k
dim FirstPageTag,LastPageTag,PrePageTag,NextPageTag,Pre_PageTag,Next_PageTag
'总页数
if nRowCount > 0 then nPageCount = PageTotal(nRowCount,nRow)

if nPageCount <= 1 then
longPageTools = PageTools(nRowCount,nRow,nPage,strPageCookieName,strUnit,strFontColor,blShort)
exit function
end if
'翻页时调用的url
strUrl = request.ServerVariables("url") & "?" & TransParam()
'跳至首页样式
FirstPageTag = "<font face=webdings>9</font>" '|<<
' FirstPageTag = "<b>|<<</b>"
'跳至末页样式
LastPageTag = "<font face=webdings>:</font>" '>>|
' LastPageTag = "<b>>>|</b>"
'跳至前10页样式
PrePageTag = "<font face=webdings>7</font>" '<<
'跳至后10页样式
NextPageTag = "<font face=webdings>8</font>" '>>
'跳至上一页样式
Pre_PageTag = "<font face=webdings>3</font>" '<
'跳至下一页样式
Next_PageTag = "<font face=webdings>4</font>" '>

if strUnit = "" then strUnit = "条记录"
if strFontColor <> "" then strCss = " style='color:" & strFontColor & "' "

strTemp = "<table><tr><td valign=""bottom""" & strCss & ">"
if nRowCount > 0 then
strTemp = strTemp & "共有<b>" & nRowCount & "</b>" & strUnit & " "
end if

'显示的首页数
dim nFirst : nFirst = nPage - 4
if nFirst < 1 then nFirst = 1

'显示的尾页数
dim nLast : nLast = nPage + 5
if nPageCount < 10 then
nLast = nPageCount
elseif nLast < 10 then
nLast = 10
end if

if nFirst > 1 then strTemp = strTemp & "<a hRef='" & strUrl & "Page=1' title='首页'" & strCss & ">" & FirstPageTag & "</a> "

for i = nFirst To nLast
strTemp = strTemp & "<a href='" & strUrl & "Page=" & i & "' " & strCss & " title='第" & i & "页'>"
if i = nPage then
strTemp = strTemp & "<b><u>" & i & "</u></b>"
else
strTemp = strTemp & i
end if
strTemp = strTemp & "</a> "
next

if nLast < nPageCount or nRowCount = 0 then strTemp = strTemp & "<a hRef='" & strUrl & "Page=" & nPageCount & "' title='第" & nPageCount & "页'" & strCss & ">" & LastPageTag & "</a> "

if nRowCount > 0 then
strTemp = strTemp & "转到:<SELECT name='page' onchange=""javascript:window.location='" & strUrl & "page=" & "'+this.options[this.selectedIndex].value;"">"
for i = 1 to nPageCount
strTemp = strTemp & "<option value='" & i & "'"
if nPage = cInt(i) then strTemp = strTemp & " selected "
strTemp = strTemp & ">第" & i & "页</option>"
next
strTemp = strTemp & "</SELECT> "
end if

if not blShort then
strTemp = strTemp & "每页显示 <input type=text name=PageRow size=2 value=" & nRow & "> " & strUnit & " "
strTemp = strTemp & "<input type=button value=定制 class='buttonface' onClick=""javascript:setRow(PageRow.value);location='" & strUrl & "page=1';"">"
strTemp = strTemp & "<script language=javascript>"
strTemp = strTemp & "function setRow(nRow){"
strTemp = strTemp & "var dNowDate = new Date();"
strTemp = strTemp & "var nYear = dNowDate.getYear() + 1;"
strTemp = strTemp & "dNowDate.setYear(nYear);"
strTemp = strTemp & "document.cookie = '" & strPageCookieName & "=' + nRow + '; expires=' + dNowDate.toGMTString();"
strTemp = strTemp & "}</script>"
end if
strTemp = strTemp & "</td></tr></table>"
longPageTools = strTemp
end Function

'页面统计
'nCount ---- 总行数
'nRow ---- 每页行数
Function PageTotal(byval nCount,byval nRow)
if not isNumeric(nRow) then exit function
if nRow <= 0 then exit function
PageTotal = cint(nCount/nRow)
if PageTotal < nCount/nRow then PageTotal = PageTotal + 1
end Function
勇敢的风
2010-11-28 · 超过119用户采纳过TA的回答
知道小有建树答主
回答量:346
采纳率:0%
帮助的人:218万
展开全部
str=split(str,"||")'str为含数烂有分页符的内容,这里将str以特定字符将其分为数组
ubound(str) 为数组最大下标,即分成宏毕伍多少部分减去1
这只是个简单的思路,还有问蔽或题再说吧。
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式