Flash and asp paging

Source: Internet
Author: User

Some Experiences of flash and asp paging
I read some of this post and learned a lot. Now I want to share it with you.
Flash is only a display function. When I read some other things, I think there seems to be a very simple implementation method for paging. basically, they are transmitted in xml format. the list component and the datagrid can be used for display. Here I use dynamic text, because I think the component is too troublesome. so I used a stupid way. I couldn't find a better solution ~~~ In the following code, list [...] is the name of dynamic text. 15 entries are displayed at a time.
// The Display program is as follows:
// Region name "list"
Stop ();
Var logList = new XML ();
Var logroot;
Var page: Number; // current page
Var Tpage: Number; // Save the total page
Var Tnum: Number; // The total Number of logs.
Var logname: String; // log category name
Var temp;
Var I: Number;
// Here I use an array to store the corresponding ID number. If I use a component, I don't have to worry about it.
Var ids = new Array (15 );
// Two buttons for paging
Bn_u.enabled = false;
Bn_d.enabled = false;
If (page = null or page <1 ){
Page = 1;
}
//------------------------------
// Clear the function;
Function myclear (){
For (I = 1; I <16; I ++ ){
Ids [i-1] = 0;
List ["lbn" + I]. _ visible = false;
List ["ltitle" + I]. text = "";
List ["lauthor" + I] = "";
List ["ltime" + I] = "";
}
}
//--------------------------------------
//--------------------------------------
Myclear ();
PageInfo. text = "reading data ...";
LogList. ignoreWhite = true;
LogList. load ("Tree_list.asp? Log_cat = "+ cat_id +" & page = "+ page );
//------------------------------------------------
// Get Data function
Function logFunc (e ){
If (e ){
Logroot = logList. firstChild;
Logname = logroot. attributes. logname;
Tpage = logroot. attributes. Tpage;
Tnum = logroot. attributes. Tnum;
Temp = logroot. firstChild;
List. ltitle1.text = Ftitle (temp. firstChild. nodeValue, 22 );
List. lauthor1 = temp. attributes. author;
List. ltime1 = temp. attributes. Addtime;
Ids [0] = temp. attributes. id;
I = 1;
List. lbn1. _ visible = true;
// Read nodes cyclically
While (temp. nextSibling! = Null ){
Temp = temp. nextSibling;
I ++;
// If it is displayed in another way, you only need to change it.
Ids [i-1] = temp. attributes. id;
List ["lbn" + I]. _ visible = true;
List ["ltitle" + I]. text = Ftitle (temp. firstChild. nodeValue, 22 );
List ["lauthor" + I] = temp. attributes. author;
List ["ltime" + I] = temp. attributes. Addtime;
}
PageInfo. text = logname + "total logs" + Tnum + "total" + Tpage + "page" + page + "page" + "15/page ";
Bn_u.enabled = true;
Bn_d.enabled = true;
} Else {
PageInfo. text = "no logs currently. ";
List. ltitle1.text = "an error occurred while reading data. Please contact the administrator! ";
}
}
// A custom format Title function, for fear that the title is too long
Function Ftitle (s, n ){
If (length (s)> n ){
S = s. substring (0, n-1) + "...";
}
Return s;
}
LogList. onLoad = logFunc;
//-------------------------------------
// Button action
Bn_up = new Object ();
// Button event to determine whether the page size exceeds the value
Bn_up.click = function (evt ){
If (page> 1 ){
_ Root. page --;
GotoAndPlay ("cycle ");
} Else {
Stop ();
}
};
Bn_d = new Object ();
Bn_d.click = function (evt ){
If (page <Tpage ){
_ Root. page ++;
GotoAndPlay ("cycle ");
} Else {
Stop ();
}
};
Bn_u.addEventListener ("click", Bn_up );
Bn_d.addEventListener ("click", Bn_d );
Cycle "cycle" has only one statement:
GotoAndPlay ("list ");
// Form a simple loop
Tree_list.asp:
// Log is my log table and log_cat is a classification table.
The following asp is clear:
<? Xml version = "1.0" encoding = "gb2312"?>
<%
Response. C
Response. CacheC
Response. AddHeader "Pragma", "no-cache"
Response. Expires = 0
Dim log_cat, page, pageSize, Tnum, Tpage, log_name
Page = TreeRequest ("page", 1)
Log_cat = TreeRequest ("log_cat", 1)
PageSize = 15
Call Tree_rs
If log_cat = 0 or log_cat = "" then
SQL = "select * from log order by written_time DESC, log_ID DESC"
Else
SQL = "select * from log, log_cat where log. cat_id = log_cat.ID and cat_id =" & log_cat & "order by written_time DESC, log_ID DESC"
End if
Rs. open SQL, conn, 1, 1
Rs. PageSize = pageSize
Tnum = rs. RecordCount
Tpage = Int (Tnum/pageSize *-1) *-1
If page = "" then page = 1
If Tnum <> 0 then rs. AbsolutePage = page
If log_cat = 0 or log_cat = "" then
Log_name = "[All categories]"
Else
Log_name = "[" & rs ("cat_name") & "]"
End if
'Output below xml
'------------------------------------------------
Response. write ("<Tree logname = '" & log_name & "'tnum ='" & Tnum & "'tpage = '" & Tpage & "'> ")
If rs. eof then
Rs. close
Else
Do while not rs. eof and pageSize> 0
Response. write ("<Trees author = '" & rs ("log_author") & "'addtime ='" & rs ("written_time ") & "'Id = '" & rs ("log_ID") & "'> ")
Response. write ("<! [CDATA ["& rs (" log_tittle ") &"]> </Trees> ")
PageSize = pageSize-1
Rs. movenext
Loop
Rs. close
End if
// Disable rs
Call Tree_rsclose
Call Tree_conclose
Response. write ("</Tree> ")
%>

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.