请aspic老师再帮帮学生!----如何把这个"二合一"页面分成"搜索页面"和"显示页面"?
分离手术----如何把这个"二合一"页面分成"搜索页面"和"显示页面"?就是说,把搜索框插入任何一个页面,只要点击"搜索"就可转到"显示页面"显示搜索到的信息?谢谢!<!--#include file="CONDB.asp"-->
<!--#include file="Cls\Paging.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Asp搜索分页</title>
<style type="text/css">
<!--
.style2 {font-size: 18px}
.style3 {font-size: 16px}
.style5 {
color: #00FF00;
font-weight: bold;
font-size: 16px;
}
.style6 {
color: #0000FF;
font-size: 16px;
}
-->
</style>
<script language="javascript">
<!--
function Page_Submit()
{
if(document.SearchForm.searchTxt.value=="")
{
alert('请输入搜索词');
return false;
}
document.SearchForm.submit();
}
function Page_Load()
{
<%
Dim oPage'定义分页对象'
Dim rsTest'定义ADODB.RecordSet对象'
Dim TErrM'定义临时错误信息对象'
Dim RecordCount
On Error Resume Next
Set oPage=New Paging'初始化分页对象'
Set rsSearch=Server.CreateObject("ADODB.RecordSet")'初始化ADODB.RecordSet对象'
'分页对象属性设置'
IF Request("searchTxt")<>"" Then
oPage.URLStr="search.asp?searchTxt="&Request("searchTxt")&"&"'设置要分页的页面URL必须加?号'
'如果需要自定义参数则设置为'
'oPage.URLStr="PagingTest.asp?ParamentName=ParamentValue&"'
'这样的格式'
oPage.SQLStr="select * From list where title like '%"&Request("searchTxt")&"%' Or word like '%"&Request("searchTxt")&"%' "'设置页面的SQL语句'
oPage.PageSize=10'设置每页显示的记录数'
oPage.CurrentPage=Clng(Request("page"))'得到当前页号'
TErrM=oPage.InitF(rsSearch,con)'分页类初始化方法必须执行'
IF TErrM<>"" Then'分页类错误判断'
Response.Write "alert('"&TErrM&"');"
End IF
IF Not rsSearch.EOF Then
RecordCount=rsSearch.RecordCount
Else
RecordCount=0
End IF
End IF
%>
}
-->
</script>
</head>
<body>
<table width="558" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="558" height="82" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="558" height="41"> </td>
</tr>
<tr>
<td height="25" valign="top"><div align="center">
<form name="SearchForm" method="get" action="search.asp">
<input type="text" name="searchTxt">
<input type="button" name="Submit" onClick="Page_Submit();" value="搜索">
</form>
</div></td>
</tr>
<tr>
<td height="16" valign="top" bgcolor="#66CCCC"><div align="right">共搜索到<%=RecordCount%>条数据</div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="77" valign="top">
<%
Dim iPage
'判断是否搜索到内容
IF Request("searchTxt")<>"" Then
IF rsSearch.EOF Then
Response.Write "没有找到任何内容"
Else
For iPage=0 To rsSearch.PageSize
%> <table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="558" height="19" valign="top"><span class="style2"><a href="<%=rsSearch("url")%>" title="<%=rsSearch("title")%>" ><%=Replace(rsSearch("title"),Request("searchTxt"),"<font color=red>"&Request("searchTxt")&"</font>")%></a></span></td>
</tr>
<tr>
<td height="41" valign="top"> <span class="style3"><%=Replace(rsSearch("word"),Request("searchTxt"),"<font color=red>"&Request("searchTxt")&"</font>")%></span><br></td>
</tr>
<tr>
<td height="17" valign="top"><span class="style5"><%=rsSearch("url")%></span></td>
</tr>
</table>
<%
rsSearch.MoveNext
IF rsSearch.EOF Then Exit For
Next
End IF
End IF
%> </td>
</tr>
<tr>
<td height="13" valign="top"><span class="style6">共<%=rsSearch.PageCount%>页 当前第<%=Request("page")%>页 <a href="search.asp?page=1&PageP=10&searchTxt=<%=Request("searchTxt")%>" title="第一页" target="_self"><font face=webdings>9</font></a>
<%
Response.Write oPage.PagingControl(rsSearch,Request("PageP"))'分页控制方法其中Request("PageP")固定写法
%>
</span></td>
</tr>
<tr>
<td height="309"> </td>
</tr>
</table>
<%
rsSearch.Close
con.close
Set rsSearch=Nothing
Set con=Nothing
%>
</body>
</html>
[ 本帖最后由 tepnidh 于 2009-9-15 19:59 编辑 ]