dreamweaverMX通用分页代码研究

嗨一会有何不可

嗨一会有何不可

2016-01-29 17:47

dreamweaverMX通用分页代码研究,dreamweaverMX通用分页代码研究
  dreamweaverMX已经正式发布了,Deamweaver4 + Deamweaver ULTRADEV 4 的组合使他成为当然的制做网页的首选工具,(好象做广告:) )
好了,进入正题,
我在以前做网页的分页时候都是用自己写的服务端脚本(我从不用ADO的分页),用了MX后发现在这里面用分页太方便了,不过代码也有点太长了,大家看下面的代码就可以知道。用过之后我发现里面recordset 的cursortype设为0分页竟然可以正常工作!这令我吃惊不少,分析了代码之后才发现MX 是用了一种挺笨的方法实现的,效率很低,所以大家还是用1吧:)
分析如下:


<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%
<!--#include file="Connections/ncarcnn.asp" --
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_ncarcnn_STRING
Recordset1.Source = "SELECT * FROM dbo.ncarinfo"

Recordset1.CursorType = 0
'这里用0也可以正常运行,但是经过分析代码可以看出,用0的效率很低,建议用1


Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%


<%
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'以下为分页代码
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%
<%
'  *** Recordset状态, 定义状态变量

Dim Recordset1_total
Dim Recordset1_first
Dim Recordset1_last

' set the record count
Recordset1_total = Recordset1.RecordCount

' set the number of rows displayed on this page
If (Recordset1_numRows < 0) Then
  Recordset1_numRows = Recordset1_total
Elseif (Recordset1_numRows = 0) Then
  Recordset1_numRows = 1
End If

' set the first and last displayed record
Recordset1_first = 1
Recordset1_last  = Recordset1_first + Recordset1_numRows - 1

' if we have the correct record count, check the other stats 处理正确的rs
If (Recordset1_total < -1) Then
  If (Recordset1_first Recordset1_total) Then
    Recordset1_first = Recordset1_total
  End If
  If (Recordset1_last Recordset1_total) Then
    Recordset1_last = Recordset1_total
  End If
  If (Recordset1_numRows Recordset1_total) Then
    Recordset1_numRows = Recordset1_total
  End If
End If
%
<%
' *** Recordset Stats: if we don't know the record count, manually count them处理错误的RS

If (Recordset1_total = -1) Then

  ' count the total records by iterating through the recordset
  Recordset1_total=0
  While (Not Recordset1.EOF)
    Recordset1_total = Recordset1_total + 1
    Recordset1.MoveNext
  Wend

  ' reset the cursor to the beginning
  If (Recordset1.CursorType 0) Then
    Recordset1.MoveFirst
  Else
    Recordset1.Requery
  End If

  ' set the number of rows displayed on this page
  If (Recordset1_numRows < 0 Or Recordset1_numRows Recordset1_total) Then
    Recordset1_numRows = Recordset1_total
  End If

  ' set the first and last displayed record
  Recordset1_first = 1
  Recordset1_last = Recordset1_first + Recordset1_numRows - 1
  
  If (Recordset1_first Recordset1_total) Then
    Recordset1_first = Recordset1_total
  End If
  If (Recordset1_last Recordset1_total) Then
    Recordset1_last = Recordset1_total
  End If

End If
%
<%
Dim MM_paramName
%
<%
' *** Move To Record and Go To Record: d
展开更多 50%)
分享

猜你喜欢

dreamweaverMX通用分页代码研究

ASP
dreamweaverMX通用分页代码研究

分页代码

Web开发
分页代码

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

JS通用代码:Tab选项卡通用js代码

Web开发
JS通用代码:Tab选项卡通用js代码

非常不错的一个JS分页效果代码值得研究

Web开发
非常不错的一个JS分页效果代码值得研究

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

分页存储过程代码

编程语言 网络编程
分页存储过程代码

一个通用的分页类

Web开发
一个通用的分页类

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

Linux指令篇:网络通讯--testparm

Linux指令篇:网络通讯--testparm

技巧:Windows XP的纯DOS之梦

技巧:Windows XP的纯DOS之梦
下拉加载更多内容 ↓