我自己是用
每一次定义
然后在来做的,.
但是我觉得很麻烦
因为做一个网站,几乎要做用到5-6次分页,
每次都要打,.
请问你们的分页,.
把代码大家一起学习,参考下
<!--#include file="CONDB.inc"-->
<!--#include file="Cls\WebSiteSetInf.asp"-->
<!--#include file="Cls\Paging.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
'网页样式初始化代码
Dim PageStyleT
Dim oWebI
Set oWebI=New WebSetInf
Set PageStyleT=New PageStyle
Call QueryStyle("用户自身信息察看",PageStyleT)
%>
<%
Dim oPage'定义分页对象
Dim rsArtL'定义ADODB.RecordSet对象
Dim ErrMsg'定义临时错误信息对象
Set oPage=New Paging'初始化分页对象
Set rsArtL=Server.CreateObject("ADODB.RecordSet")'初始化ADODB.RecordSet对象
%>
<title><%=oWebI.WebName%>-文章站内搜索</title>
<style type="text/css">
<!--
<%=PageStyleT.StyleString%>
-->
</style>
<style type="text/css">
<!--
A {
TEXT-TRANSFORM: none; TEXT-DECORATION: none
}
UNKNOWN {
TEXT-DECORATION: underline
}
body {
background-color: <%=PageStyleT.BackGround%>;
}
.style1 {font-size: 12px}
-->
</style>
<script language="JavaScript" >
function Page_Load()
{
<%
Dim ReFalse
Dim SeStr
ReFalse="T"
SeStr=""
With Response
IF Request.Form("IsSubmit")="T" Then
'stop'
Select Case Request.Form("seaCond")
Case "CSAName"
ReFalse="T"
SeStr=Request.Form("seaCond")
Case "FSAName"
ReFalse="T"
SeStr=Request.Form("seaCond")
Case "Author"
ReFalse="T"
SeStr=Request.Form("seaCond")
Case "Article_Title"
ReFalse="T"
SeStr=Request.Form("seaCond")
Case "Article_Contents"
ReFalse="T"
SeStr=Request.Form("seaCond")
Case Else
.Write "alert('搜索条件错误');"&Chr(13)
ReFalse="F"
End Select
'IF ReFalse<>"F" Then'
IF Request.Form("seaValue")="" Then
.Write "alert('搜索值为空');"&Chr(13)
ReFalse="F"
Else
SeStr=SeStr&"_like_'$"&Request.Form("seaValue")&"$'"
End IF
'End IF'
End IF
IF ReFalse<>"F" Then
IF SeStr="" Then
SeStr=Request("QueStr")
End IF
oPage.URLStr="SearchArt.asp?QueStr="&SeStr&"&"
SeStr=Replace(SeStr,"_"," ")
SeStr=Replace(SeStr,"$","%")
oPage.SQLStr="select * from ART where "&SeStr&" ORDER BY Announce_the_date DESC"'设置页面的SQL语句'
.Write "//"&oPage.SQLStr&Chr(13)
oPage.PageSize=26'设置每页显示的记录数'
oPage.CurrentPage=Clng(Request("page"))'得到当前页号'
ErrMsg=oPage.InitF(rsArtL,con)'分页类初始化方法必须执行'
End IF
IF ReFalse="F" Or ErrMsg<>"" Then
.Write "alert('"&ErrMsg&"');"&Chr(13)
End IF
End With
%>
}
</script>
</head>
<body onLoad="Page_Load();" >
<table width="467" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="47" height="13" valign="top"><div align="center"><span class="style1">编号</span></div></td>
<td width="140" valign="top"><div align="center" class="style1">标题</div></td>
<td width="70" valign="top"><div align="center" class="style1">作者</div></td>
<td width="109" valign="top"><div align="center" class="style1">所属父专区</div></td>
<td width="101" valign="top"><div align="center" class="style1">所属子专区</div></td>
</tr>
<%
IF ReFalse<>"F" And ErrMsg="" Then
Dim aPage
For aPage=0 To rsArtL.PageSize
With Response
.Write " <tr>"&Chr(13)
.Write " <td height=15 valign=top>"
.Write "<div align=center class=style1>"&rsArtL.Fields(2).Value&"</div></td>"&Chr(13)
.Write " <td valign=top><div align=left >"
.Write "<span class=style1 >"
.Write "<a href=ArticleBody.asp?ArticleID="&rsArtL.Fields(2).Value&"&SAName="&rsArtL.Fields(1).Value
.Write " title=发表于"&rsArtL.Fields(6).Value&" target=_blank >"
IF Len(rsArtL.Fields(3).Value)>11 Then
.Write Mid(rsArtL.Fields(3).Value,1,9)&"……"
Else
.Write rsArtL.Fields(3).Value
End IF
.Write "</a>"
.Write "</span></div></td>"&Chr(13)
.Write " <td valign=top >"
.Write "<div align=center class=style1 >"&rsArtL.Fields(4).Value&"</div></td>"&Chr(13)
.Write " <td valign=top><div align=center class=style1>"
.Write "<input type=text name=CSAName "
.Write "style="&"""width:105px;border: 0px none #F7F7FF;filter:alpha(opacity=50);"""&" value="
.Write rsArtL.Fields(8).Value&" readonly > </div></td>"&Chr(13)
.Write " <td valign=top><div align=center>"
.Write "<span class=style1>"
.Write "<input type=text name=CSAName "
.Write "style="&"""width:105px;border: 0px none #F7F7FF;filter:alpha(opacity=50);"""&" value="
.Write rsArtL.Fields(1).Value&" readonly > </span></div></td>"&Chr(13)
.Write " </tr>"&Chr(13)
rsArtL.MoveNext
IF rsArtL.EOF Then
Exit For
End IF
End With
Next
End IF
%>
</table>
<table width="467" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="467" height="18" valign="top"><p align="right" class="style1">共<%=rsArtL.pagecount%>页 当前第<%=Request("page")%>页 分页:<a href="<%=oPage.URLStr%>page=1&PageP=10" title="第一页" target="_self"><font face=webdings>9</font></a>
<%
Response.Write oPage.PagingControl(rsArtL,Request("PageP"))
%></p></td>
</tr>
</table>
</body>
<%
Set oPage=Nothing
con.Close
IF rsArtL.State=1 Then rsArtL.Close
Set rsArtL=Nothing
Set con=Nothing
Set PageStyleT=Nothing
Set oWebI=Nothing
%>
</html>
写起来实在太麻烦给8楼一个过去我写的代码,注意红字的部分。这段代码跟8楼的查询分也是一个功能
这个是搜索网页的</style>
<script language=JavaScript >
function searchArt()
{
if(this.searValue.value=="")
{
alert('请输入搜索值');
return false;
}
if(document.SubForm.seaCond.value=="")
{
alert('请选择搜索条件');
return false;
}
document.SubForm.seaValue.value=this.searValue.value;
document.SubForm.IsSubmit.value="T";
document.SubForm.submit();
}
function selCond_Change(val)
{
document.SubForm.seaCond.value=val;
}
</script>
</head>
<body>
<table width="473" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="24" colspan="3" valign="top"><div align="center" class="style1 style2">文章搜索</div></td>
</tr>
<tr>
<td width="297" height="24" valign="top">
<div align="right">
<input type="text" name="searValue">
</div></td>
<td width="78" valign="top"><select name="selCond" onChange="selCond_Change(this.options[this.selectedIndex].value);" >
<option selected>搜索条件</option>
<option value="CSAName" >子专区名</option>
<option value="FSAName" >父专区名</option>
<option value="Author" >作者名称</option>
<option value="Article_Title" >标题名称</option>
<option value="Article_Contents" >内容关键字</option>
</select> </td>
<td width="98" valign="top"><a href="#" target="_self" onClick="searchArt();" ><img src="Nimg/search.gif" alt="搜索" width="50" height="20" border="0"></a></td>
</tr>
</table>
<form name="SubForm" action="SearchArt.asp" target="display" method="post" >
<input name="seaValue" type="hidden" >
<input name="seaCond" type="hidden" >
<input name="IsSubmit" type="hidden" >
</form>
</body>
</html>
源代码,提交到上面的网页