Jquery. pagination. js without refreshing pages

Source: Internet
Author: User

1. Use the plug-in Jquery. pagination. js. If this JS file is not available, I can send it.

First, reference jquery. pagination. js (split page js), with pagination.css (paging style CSS ).

 

2. Page JSCodeIs 

 

<SCRIPT type = "  Text/JavaScript  " > VaR Pageindex = 0 ; //  Initial page index value          VaR Pagesize = 15 ; //  Initialize the number of items displayed on each page. modify the number of items displayed here.  $ (Function (){  Inittable (  0 ); //  Load event, initialize table data, and the page index is 0 (first page)  //  Pagecount is the total number of entries. This is a required parameter. Other parameters are optional. $ ( "  # Pagination  " ). Pagination (<% = pcount %> , {Callback: pagecallback,  //  Pagecallback () is the page flip call function. Prev_text: "  «Previous Page  "  , Next_text:  "  Next page»  "  , Items_per_page: pagesize,  Num_edge_entries:  2 ,//  Number of entries at the beginning and end of each page Num_display_entries: 6 , //  Number of consecutive pagination entries of the Main Part Current_page: pageindex, //  Current page index  });  //  Paging call  Function pagecallback (index, JQ) {inittable (INDEX );}  // Request data  Function inittable (pageindex) {$. Ajax ({type:  "  Post  "  , Datatype:  "  Text  "  , URL:  '  Http://www.cnblogs.com/tool/Reserver/ManageBuyBatchManage.ashx  ' ,//  Submit to General ProcessingProgramRequest data Data: "  Pageindex =  " + (Pageindex) + "  & Pagesize =  " + Pagesize, //  Submit two parameters: pageindex and pagesize)  Success: function (data) {$ (  " # Result TR: GT (0)  " ). Remove (); //  Remove the rows from the table whose ID is result, starting from the second row (changes depending on the page layout) $ ( "  # Result  " ). Append (data ); //  Append the returned data to the table.  }});}}); </SCRIPT>

 

 

 

 

 

3. The code in the page <body> is

 

 

<Table width = "  100%  " Border = "  0  " Cellspacing = "  0  " Cellpadding = "  0  " > <Tr> <TD width ="  60  " Align = "  Right  " > Product name: </TD> <TD width = "  200  " Align = "  Left  " > <Input type = "  Text  " Id ="  Txtkeywords  "   Class = "  Keyword  " /> </TD> <TD width = "  200  " Align = "  Left  " > <Input id = "  Search  " Type = "  Button  " Value = "  Search  "   Class = "  Submit  " /> </TD> <TD> & nbsp; </TD> </tr> </table> <Table id = "  Result  " Cellspacing = " 0  " Cellpadding = "  0  " > <Tr> <TH> item No. </Th> <TH> item name </Th> </tr> </table> <Div id = "  Pagination  "   Class = "  Right Flickr " > </Div>

 

 

 

 

 

4. The page background code is

 

 

         Protected   Int Pcount = 0 ; //  Total number of entries          Protected   Void Page_load ( Object  Sender, eventargs e ){ If (! Ispostback) {BLL. tbgoods BLL = New  Bll. tbgoods (); pcount = BLL. getrecordcount ( "  Status ='  " + ( Int ) Enum. recordstatus. Normal + "  '  " ); //  Obtain the total number of pages, that is, the actual total number of data items. If you do not understand it, select count (*) from table is the number here. }} 

 

 

 

5. The General handler fffff. ashx code is

 

 

 Using  System;  Using  System. Collections. Generic;  Using  System. LINQ;  Using  System. Web;  Using  System. text;  Using System. Data;  Namespace  Eshop. Web. admin. tool. reserver {  ///   <Summary>      ///  Abstract description of listbuybatchmanage  ///   </Summary>      Public   Class  Listbuybatchmanage: ihttphandler {  Public   Void Processrequest (httpcontext context) {context. response. contenttype = "  Text/plain  "  ; String Str = String  . Empty;  If (Context. request [ "  Pageindex  " ]! = Null & Context. request [ " Pageindex  " ]. Tostring (). length> 0  ){  Int Pageindex; //  Page count                  Int . Tryparse (context. request [ "  Pageindex  " ], Out  Pageindex );  If (Context. request ["  Pagesize  " ]! = Null & Context. request [ "  Pagesize  " ]. Tostring (). length> 0  ){  //  Number of entries displayed on the page                  Int Size = convert. toint32 (context. request [ "  Pagesize "  ]);  String Data = Bindsource (size, pageindex); context. response. Write (data); context. response. End ();}}}  # Region Refreshing pagination Public   String Bindsource ( Int Pagesize, Int  Page) {BLL. tbgoods BLL = New Bll. tbgoods (); dataset DS = BLL. getlistbypage ( "  Status ='  " + ( Int ) Enum. recordstatus. Normal + "  '  " , "" , Pagesize * Page + 1 , Pagesize * (page + 1 )); //  Obtain the DS of the data source. Stringbuilder sb =New  Stringbuilder ();  If (Ds! = Null  ){  Foreach (Datarow row In DS. Tables [ 0  ]. Rows) {sb. append (  "  <Tr> <TD>  "  ); Sb. append (row [  " Goodsuid  "  ]); Sb. append (  "  </TD> <TD>  "  ); Sb. append (row [  "  Goodsname  "  ]); Sb. append (  "  </TD> </tr>  "  );}} Return  SB. tostring ();}  # Endregion          Public   Bool  Isreusable {  Get  {  Return   False  ;}}}} 

 

 

6.

 

 

 

 

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.