asp伪继承初探_实例代码
(编辑:jimmy 日期: 2024/12/29 浏览:3 次 )
其中使用到一个分页类CPaging
复制代码 代码如下:
Class CPaging
Public RS ' RecordSet对象
Public Mark ' 指针标签
Private sSize ' 每页显示数
Private sTotal ' 总记录数
Private sPage ' 当前页码
Private sCount ' 总页码
Private Sub Class_Initialize
sSize = 20
sPage = 1
sCount = 1
End Sub
Private Sub Class_Terminate
Closeobj RS
End Sub
'每页显示数
Property Let Size(Value)
sSize = Value
End Property
Property Get Size
Size = sSize
End Property
'当前页码
Property Let Page(Value)
If Not IsNumeric(Value) Then
sPage = 1
Else
sPage = Value
End If
End Property
Property Get Page
If (sPage - 1) * sSize > sTotal Then
If sTotal Mod sSize = 0 Then
Page = Total \ sSize
Else
Page = Total \ sSize +1
End If
ElseIf sPage < 1 Then
Page = 1
Else
Page = sPage
End If
End Property
'总页码
Property Get Count
If sTotal Mod sSize = 0 Then
Count = sTotal \ sSize
Else
Count = sTotal \ sSize + 1
End If
End Property
'总记录数
Property Get Total()
Total = sTotal
End Property
Public Function Open(Byval SQLString)
Try DB.Openquery(RS,SQLString)
sTotal = RS.RecordCount
End Function
End Class
以下是调用页
复制代码 代码如下:
Dim Products
Set Products = New CPaging
With Products
.Size = 15 '每页显示数
.Page = PageNum '当前页
End With
Try Products.Open(ListSQL)
If Products.RS.Bof and Products.RS.Eof then
Response.Write("<TR><TD colspan=8>查找无记录</TD></TR>")
Else
Dim i
i = 0
Products.RS.Move (Products.Page - 1) * Products.Size
Do While Not Products.RS.Eof
Response.Write("<TR onmouseup=MouseUp(this); onmousedown=MouseDown(this); onmouseover=MouseOver(this); onclick=Click(this); onmouseout=MouseOut(this);>"&vbCrLf)
Response.Write("<TD align=middle nowrap>" & Products.RS("ProductsClassName") & "</TD>"&vbCrLf)
Response.Write("<TD align=left nowrap>" & Products.RS("ProductsName") & " </TD>"&vbCrLf)
Response.Write("</TR>"&vbCrLf)
i=i+1
If i >= Products.Size Then Exit Do
Products.RS.MoveNext
Loop
End If
当看到第8行的时候,似乎窥到了.net的影子--命名空间?
复制代码 代码如下:
Class CPaging
Public RS ' RecordSet对象
Public Mark ' 指针标签
Private sSize ' 每页显示数
Private sTotal ' 总记录数
Private sPage ' 当前页码
Private sCount ' 总页码
Private Sub Class_Initialize
sSize = 20
sPage = 1
sCount = 1
End Sub
Private Sub Class_Terminate
Closeobj RS
End Sub
'每页显示数
Property Let Size(Value)
sSize = Value
End Property
Property Get Size
Size = sSize
End Property
'当前页码
Property Let Page(Value)
If Not IsNumeric(Value) Then
sPage = 1
Else
sPage = Value
End If
End Property
Property Get Page
If (sPage - 1) * sSize > sTotal Then
If sTotal Mod sSize = 0 Then
Page = Total \ sSize
Else
Page = Total \ sSize +1
End If
ElseIf sPage < 1 Then
Page = 1
Else
Page = sPage
End If
End Property
'总页码
Property Get Count
If sTotal Mod sSize = 0 Then
Count = sTotal \ sSize
Else
Count = sTotal \ sSize + 1
End If
End Property
'总记录数
Property Get Total()
Total = sTotal
End Property
Public Function Open(Byval SQLString)
Try DB.Openquery(RS,SQLString)
sTotal = RS.RecordCount
End Function
End Class
以下是调用页
复制代码 代码如下:
Dim Products
Set Products = New CPaging
With Products
.Size = 15 '每页显示数
.Page = PageNum '当前页
End With
Try Products.Open(ListSQL)
If Products.RS.Bof and Products.RS.Eof then
Response.Write("<TR><TD colspan=8>查找无记录</TD></TR>")
Else
Dim i
i = 0
Products.RS.Move (Products.Page - 1) * Products.Size
Do While Not Products.RS.Eof
Response.Write("<TR onmouseup=MouseUp(this); onmousedown=MouseDown(this); onmouseover=MouseOver(this); onclick=Click(this); onmouseout=MouseOut(this);>"&vbCrLf)
Response.Write("<TD align=middle nowrap>" & Products.RS("ProductsClassName") & "</TD>"&vbCrLf)
Response.Write("<TD align=left nowrap>" & Products.RS("ProductsName") & " </TD>"&vbCrLf)
Response.Write("</TR>"&vbCrLf)
i=i+1
If i >= Products.Size Then Exit Do
Products.RS.MoveNext
Loop
End If
当看到第8行的时候,似乎窥到了.net的影子--命名空间?
下一篇:实用301转向到另一域名相应页面的asp代码