Asp most common paging Functions

Source: Internet
Author: User

Copy codeThe Code is as follows: rs. open SQL, conn, 1, 1
If rs. eof and rs. bof then
Response. write "<p align = 'center'> no article found </p>"
Else
TotalPut = rs. recordcount
Maxperpage = 18
If currentpage <1 then
Currentpage = 1
End if
If (currentpage-1) * maxperpage> totalput then
If (totalput mod maxperpage) = 0 then
Currentpage = totalput \ maxperpage
Else
Currentpage = totalput \ maxperpage + 1
End if
End if
If currentpage = 1 then
Showpage1 totalput, maxperpage, "infotype. asp? Id = "& request (" id ")
Showcontent ()
Showpage totalput, maxperpage, "infotype. asp? Id = "& request (" id ")
Else
If (currentpage-1) * maxperpage <totalput then
Rs. move (currentpage-1) * maxperpage
Dim bookmark
Bookmark = rs. bookmark
Showpage1 totalput, maxperpage, "infotype. asp? Id = "& request (" id ")
Showcontent
Showpage totalput, maxperpage, "infotype. asp? Id = "& request (" id ")
Else
Currentpage = 1
Showpage1 totalput, maxperpage, "infotype. asp? Id = "& request (" id ")
Showcontent
Showpage totalput, maxperpage, "infotype. asp? Id = "& request (" id ")
End if
End if
End if
%>
<%
Sub showcontent ()
%>
<Tr>
<Td height = "20" class = "blueback2"> <div align = "center"> ID </div> </td>
<Td class = "blueback2"> <div align = "center"> <a href = "javascript: selectall () "> <font color =" # FFFFFF "> select </font> </a> </div> </td>
<Td width = "355" class = "blueback2"> <div align = "center"> information title </div> </td>
<Td width = "84" class = "blueback2"> <div align = "center"> Update date </div> </td>
<Td width = "40" class = "blueback2"> <div align = "center"> click </div> </td>
<Td width = "55" class = "blueback2"> <div align = "center"> Add person </div> </td>
<Td width = "44" class = "blueback2"> <div align = "center"> edit </div> </td>
<Td width = "43" class = "blueback2"> <div align = "center"> Delete </div> </td>
<Td width = "62" class = "blueback2"> <div align = "center"> Generate [<a href = "javascript: void (null)" onClick = "window. open ('cshengcheng. asp ', '', 'width = 0, height = 0 ') "> <font color =" # FFFFFF "> return to zero </font> </a>] </div> </td>
</Tr>
<%

I = 1
Do while not rs. eof
%>

<Tr>
<Td width = "39" height = "25" bgcolor = "# D6DFF7"> <div align = "center"> <% = rs ("id ") %> </div> </td>
<Td width = "34" bgcolor = "# D6DFF7"> <div align = "center">
<Input type = "checkbox" name = "dxyid" value = "<% = rs (" id ") %>">
</Div> </td>
<Td bgcolor = "# D6DFF7"> <a href = "Article_show.asp? Id = <% = rs ("id") %> "target =" _ blank "> [<% = rs (" type_id ") %>] <% thetitle1 = rs ("title ")
Strcounts = truelen (thetitle1)
Response. write thetitle1
%> </A> </td>
<%
Datetime = rs ("datetime ")
Yname = year (datetime)
Mname = month (datetime)
If len (mname) <2 then mname = "0" & mname
Dname = month (datetime)
If len (dname) <2 then dname = "0" & dname
Foldername = yname & mname
%>
<Td bgcolor = "# D6DFF7"> <div align = "center"> <a href = "<% = htmlfolder %> <% = foldername %>/<% = rs ("id ") %>. htm "title =" view the generated static page "target =" _ blank "> <% = rs (" datetime ") %> </a> </div> </td>
<Td bgcolor = "# D6DFF7"> <div align = "center"> <% = rs ("hits") %> </div> </td>
<Td bgcolor = "# D6DFF7"> <div align = "center"> <% = rs ("author") %> </div> </td>
<Td bgcolor = "# D6DFF7"> <div align = "center"> <a href = "news_edit.asp? Dxy_id = <% = rs ("id") %> "> modify </a> </div> </td>
<Td bgcolor = "# D6DFF7"> <div align = "center"> <a href = "javascript: delxx (<% = rs (" id ") %>) "> Delete </a> </div> </td>
<Td bgcolor = "# D6DFF7"> <div align = "center"> <a href = "javascript: makehtml (<% = rs (" id ") %>) "> Generate (<a href =" javascript: void (null) "onClick =" window. open ('cshengcheng. asp? Id = <% = rs ("id") %> ', '', 'width = 0, height = 0')"> <% = rs ("shengcheng ") %>) </a> </div> </td>
</Tr>
<%
I = I + 1
If I> maxperpage then exit do
Rs. movenext
Loop
%>
<Tr>
<Td height = "20" class = "blueback2"> <div align = "center"> ID </div> </td>
<Td class = "blueback2"> <div align = "center"> <a href = "javascript: selectall () "> <font color =" # FFFFFF "> select </font> </a> </div> </td>
<Td class = "blueback2"> <div align = "center"> information title </div> </td>
<Td class = "blueback2"> <div align = "center"> Update date </div> </td>
<Td class = "blueback2"> <div align = "center"> click </div> </td>
<Td class = "blueback2"> <div align = "center"> Add By </div> </td>
<Td class = "blueback2"> <div align = "center"> edit </div> </td>
<Td class = "blueback2"> <div align = "center"> Delete </div> </td>
<Td class = "blueback2"> <div align = "center"> Generate </div> </td>
</Tr>
<%
End sub
%>

<Tr>
<Td height = "20" colspan = "9" bgcolor = "# D6DFF7"> <label>
<Input type = "button" name = "dxydo" value = "select all" onClick = "javascript: selectall ()">
<Input type = "submit" name = "dxydo" value = "delete" onClick = "{if (confirm ('Are you sure you want to delete the selected information') {document. formselect. submit (); return true;} return false;} ">
<Input type = "submit" name = "dxydo" value = "generate">
<Input type = "submit" name = "dxydo" value = "mobile">
</Label> </td>
</Tr>
<%
Function showpage (totalnumber, maxperpage, filename)
%>
<Tr>
<Td height = "20" colspan = "9" bgcolor = "# D6DFF7">
<%
Dim n
If totalnumber mod maxperpage = 0 then
N = totalnumber \ maxperpage
Else
N = totalnumber \ maxperpage + 1
End if
%>
<Div align = "center"> total <% = totalnumber %>/<% = maxperpage %>,

Current page <% = currentpage %>/<% = n %>
<% If currentpage <2 then %>
[Homepage] [Previous Page]
<% Else %>
<A href = "<% = filename %>"> <font color = "red"> [homepage] </font> </a> <a href = "<% = filename %> & page = <% = currentpage-1 %> "> <font color =" red "> [Previous page] </font> </a>
<% End if %> <% if n-currentpage <1 then %>
[Next page] [last page] <% else %> <a href = "<% = filename %> & page = <% = currentpage + 1%>"> <font color =" red "> [Next page] </font> </a> <a href =" <% = filename %> & page = <% = n %> "> <font color = "red"> [last page] </font> </a>
<% End if %>
Go to: <select name = "dd" class = "lupus"

OnChange = "location. href = this. options [this. selectedIndex]. value">
<% For j = 1 to n
If currentpage = j then
%> <Option value = "<% = filename %> & page = <% = j %>" selected> <% = j %> </option>
<%
Else
%>
<Option value = "<% = filename %> & page = <% = j %>"> <% = j %> </option>
<%
End if
Next
%>
</Select>
</Div> </td>
</Tr>
<%
End function
%>
<%
Function showpage1 (totalnumber, maxperpage, filename)
%>
<Tr>
<Td height = "20" colspan = "9" bgcolor = "# D6DFF7">
<%
Dim B
If totalnumber mod maxperpage = 0 then
B = totalnumber \ maxperpage
Else
B = totalnumber \ maxperpage + 1
End if
%>
<Div align = "center"> total <% = totalnumber %>/<% = maxperpage %>,

Current page <% = currentpage %>/<% = B %>
<%
Dxystart = currentpage-5
If dxystart <1 then dxystart = 1
Dxyend = currentpage + 5
If dxyend> B then dxyend = B
For dxy = dxystart to dxyend
If dxy = currentpage then
Response. write "[<a href =" & filename & "& page =" & dxy & ">" & "<font color = red>" & dxy & "</font>" & "</a>]" & ""
Else
Response. write "[<a href =" & filename & "& page =" & dxy & ">" & dxy & "</font>" & "</a>]" & ""
End if
Next
%>
</Div> </td>
</Tr>
<%
End function
%>
</Form>
</Table>
<%
Rs. close
Set rs = nothing
Conn. close
Set conn = nothing
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.