Asp.net uses the fck pagination character for large article pagination

Source: Internet
Author: User

Method:
/// <Summary>
/// Document paging Function
/// </Summary>
/// <Param name = "content"> content </param>
/// <Param name = "currentpage"> current page number </param>
/// <Param name = "pageurl"> current page address </param>
Protected string [] articlepage (string content, int currentpage, string pageurl)
{
String [] result = new string [2];
Int pagecount = 0; // Number of pages
Content = content. replace ("<Div style = \" Page-break-after: Always \ "> <span style = \" display: None \ "> & nbsp; </span> </div> "," [-- page --] "); // Replace the default paging character generated by fck in IE with the custom paging character.
String [] tempcontent = system. text. regularexpressions. regEx. split (content, "\ u005b -- page --]"); // obtain the Escape Character "\ u005b" "["
Pagecount = tempcontent. length;
String outputcontent = ""; // content to be output
If (pagecount <= 1)
{
Outputcontent = content; // document content
Result [0] = string. empty;
}
Else
{
String pagestr = ""; // pagination string
If (currentpage! = 1)
{
// If no parameter is set, change "& CP =" "? CP ="
Pagestr + = "<a class = 'prev' href =" + pageurl + "& CP =" + (currentpage-1) + "> <previous page </a> ";
}
For (INT I = 1; I <= pagecount; I ++)
{
If (I = currentpage)
Pagestr + = ("<SPAN class = 'active'> [" + I + "] </span> ");

Else
{
// If no parameter is set, change "& CP =" "? CP ="
Pagestr + = ("<a class = 'num' href =" + pageurl + "& CP =" + I + "> [" + I + "] </a>" );
}
}
If (currentpage! = Pagecount)
{
// If no parameter is set, change "& CP =" "? CP ="
Pagestr + = "<a class = 'Next' href =" + pageurl + "& CP =" + (currentpage + 1) + "> next page >></A> ";
}
Result [0] = pagestr;
Outputcontent = tempcontent [currentpage-1]. tostring ();
}
Result [1] = outputcontent;
Return result;
}

// Call
Public partial class jxjl: system. Web. UI. Page
{
Sqlconnection conn = new sqlconnection (sqlhelper. Conn );
Sqlcommand cmd;
Sqldatareader Dr;
String [] REE = new string [2];
Int cpage = 1;
String purl = "";
Protected void page_load (Object sender, eventargs E)
{
If (! Page. ispostback)
{
If (request. querystring ["ID"]! = NULL)
{

// Paging address
Purl = "jxjl. aspx? Id = "+ request. querystring [" ID "] + "";
Sel ();
}
Else
{
// Upload to the error page
// BIND ();
}
}

}
Private void sel ()
{
Try
{
If (conn. State = connectionstate. Closed)
{
Conn. open ();
}
String code = "select title, content from zj_article where id = '" + request. querystring ["ID"]. tostring () + "'";
Cmd = new sqlcommand (Code, Conn );
Cmd. commandtimeout = 200;

Dr = cmd. executereader ();
If (dr. hasrows)
{
While (dr. Read ())
{
If (request. querystring ["CP"]! = NULL)
{
Cpage = convert. toint32 (request. querystring ["CP"]. tostring ());
}
REE = articlepage (Dr ["content"]. tostring (), cpage, purl );
// Display the page number
This. labpage. Text = REE [1]; this. labcontent. Text = REE [0];
}

}
}
Finally
{
If (conn. State = connectionstate. open)
{
// Dr. Close ();
Conn. Close ();
}
}
}
}
}
// Add two labels to the foreground
Labpage (page number) labcontent (content)

 

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.