Source: http://blog.mvpcn.net/jaron/archive/2004/07/15/2159.aspx
In the past two days, I have seen a friend raise an automatic paging question and posted some of the code in my original system for your reference to see if there are any improvements or better suggestions, in fact, most of our company's recent projects use c #, and ASP is rarely used...
Only a part of the code is posted here. If you are interested, you can
Http://demo.jaron.cn test, management http://demo.jaron.cn/admintools account and password are both demo
Demo of the generated page:
---------------
Http://demo.jaron.cn/SiteManager/59/2004-05/20040517001558-101502.html
Http://demo.jaron.cn/SiteManager/59/2004-05/20040517001558-101502_2.html
Http://demo.jaron.cn/SiteManager/59/2004-05/20040517001558-101502_3.html
Http://demo.jaron.cn/SiteManager/59/2004-05/20040517001558-101502_4.html
JavaScript script
======================================
The following is a code snippet:
Function submitPostIfRame (mode ){
Var sMarkup = doc_html.getHTML (); // retrieve data from the html editor
With (document. forms [0]) {
Doc_html.document.open ();
Doc_html.document.write (sMarkup );
Doc_html.document.close ();
Doc_html.document.body.innerHTML = sMarkup;
Var oBody=doc_html.doc ument. body;
Var oHTML = "";
For (var I = 0; I if (I! = OBody. childNodes. length-1 ){
If (oBody. childNodes [I]. nodeType = 3 ){
OHTML + = oBody. childNodes [I]. nodeValue + "";
} Else {
OHTML + = oBody. childNodes [I]. outerHTML + "";
}
} Else {
If (oBody. childNodes [I]. nodeType = 3 ){
OHTML + = oBody. childNodes [I]. nodeValue;
} Else {
OHTML + = oBody. childNodes [I]. outerHTML;
}
}
}
News_content.value = oHTML
}
Return true;
}
ASP script
====================
The following is a code snippet:
Function calculate_pagination (strContent, pSize)
On Error Resume Next
Dim aCon, intfor, intCount, strTemp, strTemp2
ACon = Split (strContent, "",-1, 1)
IntCount = UBound (aCon)
StrTemp = ""
StrTemp2 = ""
Page = 1
For intfor = 0 To intCount
StrTemp = strTemp & aCon (intfor)
StrTemp2 = strTemp2 & RemoveHTML (aCon (intfor ))
'Strtemp2 = strTemp2 & aCon (intFor)
If Len (strTemp2)> = pSize Then
Page = Page + 1
StrTemp = ""
StrTemp2 = ""
End If
Next
'If strTemp2 <> "" Then Page = Page-1
Calculate_pagination = Page
If Err. Number <> 0 Then
Calculate_pagination = 1
Err. Clear
End If
End Function
Function get_page_text (strContent, pagenum, totalpage, pSize)
ACon = Split (strContent, "",-1, 1)
IntCount = UBound (aCon)
StrTemp = ""
StrTemp2 = ""
Page = 1
For intfor = 0 To intCount
StrTemp = strTemp & aCon (intfor)
StrTemp2 = strTemp2 & RemoveHTML (aCon (intfor ))
'Strtemp2 = strTemp2 & aCon (intFor)
If Len (strTemp2)> = pSize Then
If pagenum = Page Then
Get_page_text = strTemp
Exit
End If
Page = Page + 1
StrTemp = ""
StrTemp2 = ""
End If
Next
If strTemp2 <> "" And pagenum> Page-1 Then get_page_text = strTemp
End Function