Content paging simple implementation code and Xiang solo (C #)

zhaozj2021-02-16  95

Online already uses ASP to display code on the article content paging, I have no time detailed research. Today, a few long articles have been released. In order to facilitate the browsing of netizens, they will write down the following code. Because our program is written in c # .net, about C # this example, the data online is also found; so there is only to start analysis from the program structure, but the program is used for a long time, and sweat! Insufficient, please give pointers, what a better way is there, please tell us.

Display content part:

// Source: Network Empire (wren.cn/wrclub.net)// Author: Fuxing // define variables int i, start, stop, t, stat, statt, pp, pagecount, pagesize; // initial value of the variable stat = 0; Statt = 0; START = 0; // Start the string position of the query, initial 0Stop = 0; Pagesize = 2000; // Define at least the number of strings per page will be displayed. PageCount = 0;

// Get the current number of pages PA = Request.Params ["PAGE"]; if (PA == "|| PA == NULL) PA =" 1 "; PP = Convert.TOINT32 (PA);

// Get content articles = RS ["contenttxt"]. TOSTRING ();

/ / Decision Length is greater than the defined number of strings at least the number of strings IF (Articles) // if it is greater than the number of strings, we can display {t = articles = articles; = PageSize; / / Get a rough total page number / / According to the current number of pages currently (i = 0; i ", start pagesize); / / Find Page points IF (Stat <= 0) // If stat = articles, start pagesize; // find the location of the point point; here you can set your own points yourself Judgment} if (stat <= 0) // If you do not find a page point, you can't paid, you don't need to do other labor; otherwise, you will make paging articles kettlext = articles; // Pay the result to be exported Variable Else {stop = stat; // Page point location is also the end point of this page IF (start pagesize> = articles) // If the start position to the query exceeds the length of the entire content, then The end position of this page is the end point stop = articles; if (pp == i 1) // If it is current, then the contents of the current page pro ArticleText = articles ketxt.substring (Start, stop-start); // Take the start position of the content to the end position of the string output start = stat; // Take the end position as the starting position of the next page PageCount ; // Get the total number of pages}}}}}}}} Power page (here simple too much)

String html; // Define the paging code variable

IF (PageCount> 1) // We display pages when the number of pages is greater than 1

{

For (i = 1; i <= pagecount; i )

{

IF (i == pp) // If it is a current page, bold display

HTML = " [" i "] ";

Else

HTML = " [" i "]

}

IF (PP 1> PageCount) // Show next page, easy to browse

HTML = " [Next] ;

Else

HTML = " [next page] ;}

You can join the above code! If you have any questions, please go to the Net Forum Postage, address: http://bbs.wrclub.net

转载请注明原文地址:https://www.9cbs.com/read-22783.html

New Post(0)