(2).ASP通用的分页程序,只要传递5个参数,就可以直接使用,放在表格里面或者body里面就可以,各问大虾帮我看看,是否还可以优化一下代码
if (j>=(m_FieldCount-m_FieldCount_Show)) then
response.Write "<td>"
if j=m_FieldIndex_i then
'如果只有一个连接参数
if(m_Link_back_str="") then
response.Write "<a href='"+m_Link_pro_str+cstr(m_recordset(j))+"' target='_blank'>"+cstr(m_recordset(j))+"</a>"
else
response.Write "<a href='"+m_Link_pro_str+cstr(m_recordset(j))+m_Link_back_str+m_Link_back_str_FieldIndex_str+"' target='_blank'>"+cstr(m_recordset(j))+"</a>"
end if
else
response.Write cstr(m_recordset(j))
end if
response.Write "</td>"
end if
next
%>
</tr>
<%
'response.Write cstr(i)+m_recordset("bt")
Permsg = Permsg - 1
m_recordset.Movenext
i=i+1
Loop
%>
</table>
<%
itemStr = ""
For Each item in Request.Form
if item <> "Page_Value" And item <> "Page_Value_Max" then
itemStr = itemStr & "&" & item & "=" & Server.HTMLEncode(Request.Form(item))
End if
Next
if itemStr = "" then
For Each item in Request.QueryString
if item <> "Page_Value" And item <> "Page_Value_Max" then
itemStr = itemStr & "&" & item & "=" & Server.HTMLEncode(Request.QueryString(item))
End if
Next
End if
%>
<form name="Page_Value_Form" method="POST" action="<%=Request.ServerVariables("URL")%>?Page_Value_Max=<%=Page_Value_Max%><%=itemStr%>">共<b><font color="#FF0000"><%=m_recordset.RecordCount%></font></b>条 <b><font color="#FF0000"><%=Page_Value%>/<%=Page_Value_Max%></font></b> <a href="javascript:Next_Or_Previous_Value_Page(1)">首页</a> <a href="javascript:Next_Or_Previous_Value_Page(2)">上一页</a> <a href="javascript:Next_Or_Previous_Value_Page(3)">下一页</a> <a href="javascript:Next_Or_Previous_Value_Page(4)">末页</a> <input type="submit" value="转到"> <input type="text" name="Page_Value" size="3">页</form>
<script language="JavaScript">
function Next_Or_Previous_Value_Page(vChar){
if(vChar == 1)location.href="<%=Request.ServerVariables("URL")%>?Page_Value=1&Page_Value_Max=<%=Page_Value_Max%><%=itemStr%>";
if(vChar == 2)location.href="<%=Request.ServerVariables("URL")%>?Page_Value=<%if Page_Value - 1 = 0 then Response.Write 1 Else Response.Write Page_Value - 1 end if%>&Page_Value_Max=<%=Page_Value_Max%><%=itemStr%>";
if(vChar == 3)location.href="<%=Request.ServerVariables("URL")%>?Page_Value=<%if Page_Value + 1 >= Page_Value_Max then Response.Write Page_Value_Max Else Response.Write Page_Value + 1 end if%>&Page_Value_Max=<%=Page_Value_Max%><%=itemStr%>";
if(vChar == 4)location.href="<%=Request.ServerVariables("URL")%>?Page_Value=<%=Page_Value_Max%>&Page_Value_Max=<%=Page_Value_Max%><%=itemStr%>";
}
</script>
<%
Else
Response.Write "<tr><td><center>无您所需的内容</center></td></tr>"
End if
m_recordset.Close
Set m_recordset = Nothing
Else
Response.Write("<script>alert('输入的值超过最大页,点击确定返回');history.back()</script>")
End if
Else
Response.Write("<script>alert('非法请求,点击确定返回');history.back()</script>")
End if
Else
Response.Write("<script>alert('非法请求,点击确定返回');history.back()</script>")
End if
%>
调用这个文件的例子:
<html>
<body>
<%
Application("id")="28"
Application("sql_str")="select ksid,bt,rq from outinfo where ksid="+Application("id")
Application("FieldCount")=3 '显示字段个数
Application("FieldCount_Show")=2 Application("FieldIndex")=2 '第m_FieldIndex需要进行超连接
Application("Link_pro")="list.asp?t=" '超连接前缀
Application("Link_back")="&id=" '超连接前缀
Application("Link_back_str_FieldIndex_i")=1
%>
<iframe marginWidth=0 marginHeight=0 marginRight=0
src="temp_lll.asp" frameBorder=no
width=550 scrolling=no height=300>
</iframe>
</body>
</html>