当前位置:首页>网络学院>网页制作>Dreamweaver教程>文章内容
广告位出租 广告位出租

用Dreamweaver+ASP实现分页技术的参考

[ 来源:www.it55.com | 作者: | 时间:2007-06-28 | 收藏 | 推荐 ] 【

广告位出租


Next 
End If 
%> 


  4.这是就完成表格的第一行的工作。下来也是关键,即分页的连接。光标在第2行第一个单元格中时在代码窗口插入:

<% showPageInfo Recordset1.PageCount,PageNo %> 的代码。右边的2个单元格将其合并,在代码中插入:

<% showPageNavi Recordset1.PageCount,PageNo %>

  的代码。

  5.大功告成!这时感快预览一下吧。。。。

  表格的全部代码如下:

以下是引用片段:
<table width="710" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#333333"> 
<% 
If Recordset1.EOF OR Recordset1.BOF Then 
Else 
For I=1 To RPP 
%> 
<tr bgcolor="#FFFFFF"> 
<td width="30" align="center"><%=(PageNo-1)*RPP+I%></td> 
<td><%=(Recordset1.Fields.Item("编号").Value)%></td> 
<td><%=(Recordset1.Fields.Item("公司名称").Value)%></td> 
</tr> 
<% 
Recordset1.MoveNext 
If Recordset1.EOF OR Recordset1.BOF Then Exit For 
Next 
End If 
%> 
<tr bgcolor="#FFFFFF"> 
<td colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="2"> 
<tr bgcolor="#006699" class="w12"> 
<td width="121" align="center"><% showPageInfo Recordset1.PageCount,PageNo %> 
</td> 
<td width="573" align="center"> 
<% showPageNavi Recordset1.PageCount,PageNo %> 
</td> 
</tr> 
</table></td> 
</tr> 
</table>

  这时你去点应用程序中的“服务器行为”中的记录集,在代码中就显示为一下代码,也是我的原代码:

以下是引用片段:
<% 
Dim I 
Dim RPP’RPP:指定每页显示的记录条数, 
Dim PageNo 
I=1 
RPP=50 
PageNo=CInt(Request("PageNo")) 
Dim Recordset1 
Dim Recordset1_numRows 
Set Recordset1 = Server.CreateObject("ADODB.Recordset") 
Recordset1.ActiveConnection = MM_数据库名_STRING 
Recordset1.Source = "SELECT * FROM 表名 ORDER BY 编号 ASC" 
Recordset1.CursorType = 1 
Recordset1.CursorLocation = 2 
Recordset1.LockType = 1 
Recordset1.Open() 
Recordset1_numRows = 0 
Recordset1.PageSize=RPP 
If PageNo<=0 Then PageNo=1 
If PageNo>Recordset1.PageCount Then PageNo=Recordset1.PageCount 
Recordset1.AbsolutePage=PageNo 
Sub ShowPageInfo(tPageCount,cPageNo) 
Response.Write "第"&cPageNo&"页[共"&tPageCount&"页]" 
End Sub 
Sub ShowPageNavi(tPageCount,cPageNo) 
If cPageNo<1 Then cPageNo=1 
If tPageCount<1 Then tPageCount=1 
If cPageNo>tPageCount Then cPageNo=tPageCount 
Dim NaviLength 
NaviLength=20 ’NaviLength:显示的数字链接个数 
Dim I,StartPage,EndPage 
StartPage=(cPageNo\NaviLength)*NaviLength+1 
If (cPageNo Mod NaviLength)=0 Then StartPage=StartPage-NaviLength 
EndPage=StartPage+NaviLength-1 
If EndPage>tPageCount Then EndPage=tPageCount 
If StartPage>1 Then 
Response.Write "<a class=""pageNavi"" href=""?PageNo=" & (cPageNo-NaviLength) & """><<</a> " 
Else 
Response.Write "<font color=""#CCCCCC""><<</font> " 
End If 
For I=StartPage To EndPage 
If I=cPageNo Then 
Response.Write "<b>"&I&"</b>" 
Else 
Response.Write "<a class=""pageNavi"" href=""?PageNo=" & I & """>" & I & "</a>" 
End If 
If I<>tPageCount Then Response.Write "&nbsp;" 
Next 
If EndPage<tPageCount Then 
Response.Write " <a class=""pageNavi"" href=""?PageNo=" & (cPageNo+NaviLength) & """>>></a>" 
Else 
Response.Write " <font color=""#CCCCCC"">>></font> " 
End If 
End Sub 
%> 


  不过有一个缺点就是:如当你想找99页时点>>9次,要是有一个输入框,输入99后回车就到99就完美了。不知在DW+ASP中再怎么修改一下就能达到呢?期待。

(阅读次数:

返回顶部
共2页: 上一页 [1] 2 下一页  
广告位出租

网友评论

[以下评论为网友观点,不代表本站。请自觉遵守互联网相关政策法规,所有连带责任均有评论者自负。]
[不超过250字]