dreamweaverMX通用分页代码研究

2016-01-29 17:47 1 1 收藏

dreamweaverMX通用分页代码研究,dreamweaverMX通用分页代码研究

【 tulaoshi.com - ASP 】

  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

来源:https://www.tulaoshi.com/n/20160129/1502930.html

延伸阅读
在开始讲述之前,先提两个业内用研人士经常会被问到的问题,①为什么要做用研?②用研能为业务做些什么呢?为了回答这两个问题,我将自己从事分析行业多年的战略规划法、业务分析法、用户研究方法等贯通起来,形成了以下的一些方式方法,即通用思维在用户研究中的应用。方法无边界,融会贯通将使方法更加行之有效,希望以下内容能给大家一些启发...
标签: Web开发
package com.shaccp.web.util; import java.util.List; public class PageBean { /** * * * @author ppy 2008-10-18 14:3:56 * totalRecords 总记录数 * list 保存分页的数据 * pageNo 当前页 * pageSize 页大小 * query 保存用户查询的字符串 * pageAction 操作分页的Servlet或Action(struts) * method (struts中Action对应的meth...
标签: Web开发
%@ page contentType="text/html; charset=gb2312" language="java"% %@ page import = "java.util.*"% %@ page import = "java.io.*"% %@ page import = "java.sql.*"% html head title教师信息查询/title style type="text/css" !-- .style1 {  font-family: "华文行楷";  color: #FFFFFF; } -- /style link href="default.css" r...
标签: Web开发
从开始学习到使用ASP到现在也写了不少程序了,最令人头痛的是写数据分页,每次都是由于几个变量名或几个参数的不同,因而需要每次都写哪一段冗长而又繁杂的分页代码,代码长了使得程序的可读性变差,容易出差,调试半天也找不出错在哪里,所以慢慢的我开始使用一些网上的提供的分页函数或分页类。的确省事不少,但是通常的函数和类的做法都是就...
标签: Web开发
代码如下: !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" html xmlns="http://www.w3.org/1999/xhtml" head titlejquery分页控件/title script src="jquery-1.3.min.js" type="text/javascript"/script /head body div class="pager"/div !--div s...

经验教程

713

收藏

71

精华推荐

通用分页存储过程真的有注入漏洞吗?

通用分页存储过程真的有注入漏洞吗?

揹又寸背拥抱2

一个分页代码例子

一个分页代码例子

E花开不败L

Hibernate通用数据库操作代码

Hibernate通用数据库操作代码

奔跑的买手

微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部