Object-based solution for ASP paging

Source: Internet
Author: User
Objects | paging | Resolve on the forum there are many articles about ASP pagination, the basic idea is consistent, I put these netizen's thought to deepen a bit, use JavaScript to set up on a layer of object based coat, so call up don't appear disorderly, other words don't say more, see the annotation in the program.

Below is the source program:
<script Language=javascript runat=server>
function Trim (str)//Remove the trailing space of the string
{var tmpstr=new String (str)
Return Tmpstr.replace (/(^\s*) | ( \s*$)/g, "");
}
</script>


<script Language=javascript runat=server>
// ************************************************************************
Script Compont Object Model
Design for Active Server Pages
//
Copyright 2003 Version 1.0
Made by Yinshuguang
All Rights Reserved.
// ************************************************************************

function Jpagenavbar () {
_lb__prototype ();
}
function _lb__prototype ()
{

Public members
Jpagenavbar.prototype.pagesize= "0"
Jpagenavbar.prototype.recordcount= "0"//Total record number
Jpagenavbar.prototype.pagecount= "1"//Total Pages
Jpagenavbar.prototype.currentpage= "1"

Jpagenavbar.prototype.pnwidth= "100%"
Jpagenavbar.prototype.pnalign= "Right"
Jpagenavbar.prototype.plwidth= "100%"//Table width
Jpagenavbar.prototype.plalign= "right"//table alignment

Private members

Public methods
Jpagenavbar.prototype.getcurrentpage=_getcurrentpage
JPageNavbar.prototype.pnDisplay = _pn_show;
JPageNavbar.prototype.plDisplay = _pl_show;

Private methods


Scope implementation in _lb__prototype function

function _getcurrentpage () {
var pageno=new String ()//the page currently displayed
Get current Page
PageNo = Request.QueryString ("PageNo")
Pageno=ftrim (PageNo)
If the page is not selected, the first page is displayed by default;
if (pageno== "") {
PageNo = 1
}
This. Currentpage=pageno
Return PageNo
}
function _pl_show () {

var strbuilder=new String ()
Strbuilder= ""
var p= (this. Currentpage-(this. CURRENTPAGE%10))/10//Calculate page number of pages displayed
The first group is the No. 0 clan

strbuilder+= "<table border=\" 0\ "cellpadding=\" 0\ "cellspacing=\" "0\" "
strbuilder+= "Width=\" "+this." plwidth+ "\" align=\ "" +this. plalign+ ">"

strbuilder+= "<tr>"
strbuilder+= "<td valign=\" middle\ "align=\" right\ "> Pagination:"

if (this. Currentpage==1) {
strbuilder+= "<font face=\" Webdings\ "color=\" #ff0000 \ ">9</font>"
}
else{
strbuilder+= "<a href=\"? Pageno=1\ "title=\" Home \ "><font face=\" Webdings\ ">9</font></a>

"
}
on page 10
if (p*10>0) {
strbuilder+= "<a href=\"? pageno= "+ (p*10) +" \ "title= on 10 pages ><font

Face=\ "Webdings\" >7</font></a> "
}
strbuilder+= "<b>"
Page-List
for (Var i=p*10+1;i<=p*10+10;i++) {
if (i==this. CurrentPage) {
strbuilder+= "<font color=\" #000000 \ ">" +i+ "</font>"
}
else{
strbuilder+= "<a href=?" pageno= "+i+" title=\ "goto: +i+" page \ ">" +i+ "</a>"
}
if (i>=this. PageCount) break;
}
strbuilder+= "</b>"
Show next 10 pages
if (i<this. PageCount) {
strbuilder+= "<a href=\"? pageno= "+i+" \ "title=\" next 10 pages \ "><font

Face=\ "Webdings\" >8</font></a> "
}
Show last
if (this. Currentpage==this. PageCount) {
strbuilder+= "<font face=\" Webdings\ "color=\" #000000 \ ">:</font>"
}
else{
strbuilder+= "<a href=?" Pageno= "+this. pagecount+ "title=\" End \ "><font

Face=\ "Webdings\" >:</font></a> "
}
strbuilder+= "</td></tr></table>"
Response.Write (Strbuilder)
}
function _pn_show () {
var strbuilder=new String ()



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.