. Net is a page similar to Google.

Source: Internet
Author: User
Code 
Public Static String Pagestrout ( Double Pagesize, Int Curpage, Double Rscount, String Pagepara)
{
Double Pagecountdouble = Rscount / Pagesize;
Int Pagecount = Convert. toint32 (math. Ceiling (pagecountdouble ));
If (Pagecount < 1 ) {Pagecount = 1 ;}
If (Curpage < 1 ) {Curpage = 1 ;}
If (Curpage > Pagecount) {curpage = Pagecount ;}
Int Pagelistnum = 10 ;
Int Step = 5 ;
Int Prepage = Curpage - 1 ;
Int Nextpage = Curpage + 1 ;
Int Pagefromnum = Curpage - Step;
Int Pageendnum = Curpage + Step;


If (Pagecount < Step)
{
Pagefromnum = 1 ;
Pageendnum = Pagecount;
} Else If (Pagecount < Pagelistnum)
{
Pagefromnum = 1 ;
Pageendnum = Pagecount;
} Else If (Pageendnum > Pagecount)
{
Pageendnum = Pagecount;
If (Pageendnum - Pagefromnum) < Pagelistnum)
{Pagefromnum = Pageendnum - Pagelistnum + 1 ;}
} Else
{
If (Pagefromnum < 1 )
{
Pagefromnum = 1 ;
Pageendnum = Curpage + Step - 1 ;
}
}

Stringbuilder pagestr = New Stringbuilder ();
// Pagestr. append ("<style>. pageclass {font-family: verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding-top: 0px; text-align: Left; margin-top: 2px ;}");
Pagestr. append ( " <Style> " );
Pagestr. append ( " . Pageclass ul {float: Left; margin: 5px ;} " );
Pagestr. append ( " . Pageclass ul Li {margin-Right: 3px; float: Left ;} " );
Pagestr. append ( " . Pageclass ul Li a {border: 1px solid # d8dfef; color: # 01669a; text-Decoration: none; padding: 1px 4px; width: 20px; Height: 15px ;} " );
Pagestr. append ( " . Pageclass {font-family: verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding-top: 0px; text-align: Left; margin-top: 2px ;} " );
Pagestr. append ( " . Pageclass ul Li A: hover {color: # fe6601; text-Decoration: none; Border: 1px solid # d8dfef; padding: 1px 4px; Height: 18px ;} " );
Pagestr. append ( " </Style> " );
Pagestr. append ( " <Div class = \ " Pageclass \ " > " );
Pagestr. append ( " <Ul> " );
Pagestr. append ( " <Li> <strong> " + Curpage + " / " + Pagecount + " & Nbsp; </strong> </LI> " );
Pagestr. append ( " </Ul> " );

If (Curpage ! = 1 ){
Pagestr. append ( " <Ul> " );
Pagestr. append ( " <Li> " );
Pagestr. append ( " <A href =? Curpage = 1 " + Pagepara + " > Homepage </a> & nbsp; <a href =? Curpage = 1 & " + Pagepara + " > Previous page </a> " );
Pagestr. append ( " </LI> " );
Pagestr. append ( " </Ul> " );
}

Pagestr. append ( " <Ul> " );

For ( Int I = Pagefromnum; I <= Pageendnum; I ++ )
{
Pagestr. append ( " <Li> " );
If (Curpage = I)
{Pagestr. append (I. tostring ());}
Else
{
Pagestr. append ( " <A href =? Curpage = " + I. tostring () + "" + Pagepara + " > " + I. tostring () + " </A> " );
}
Pagestr. append ( " </LI> " );
}

Pagestr. append ( " </Ul> " );

If (Curpage ! = Pagecount)
{
Pagestr. append ( " <Ul> <li> " );
Pagestr. append ( " <A href =? Curpage = " + Nextpage + " & " + Pagepara + " > Next page </a> & nbsp; <a href =? Curpage = " + Pagecount + " & " + Pagepara + " > Last page </a> " );
Pagestr. append ( " </LI> </ul> " );

}
Pagestr. append ( " </Div> " );


Return Pagestr. tostring ();


}

 

As shown above, pagesize is the number of items to be explicitly displayed on each page. curpage indicates the current page, rscount indicates the total number of records, and pagepara indicates the parameters at the end of the page,

Suppose the page is www.gosoa.com.cn/index.aspx? Searchtype = A & keyword = 'gosoa ', pagepara =Searchtype = A & keyword = 'gosoa' 

OK. If you have any questions, leave a message.

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.