Asp. Net (jquery. pagination. js)

Source: Internet
Author: User

 

Jquery. pagination. js is used to implement the effect of refreshing new pages.

1. Plug-in parameter list

 

 

2. Page Content:

<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default. aspx. cs" Inherits = "_ Default" %>

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<Html xmlns = "http://www.w3.org/1999/xhtml">

<Head runat = "server">

<Title> Porschev ---- refreshing page flip </title>

<Script src = "Script/jquery-1.4.1.min.js" src = "Script/jquery-1.4.1.min.js" type = "text/javascript"> </script>

<Script src = "Script/jquery. pagination. js" mce_src = "Script/jquery. pagination. js" type = "text/javascript"> </script>

<Script src = "Script/tablecloth. js" mce_src = "Script/tablecloth. js" type = "text/javascript"> </script>

<Link href = "Style/tablecloth.css" mce_href = "Style/tablecloth.css" rel = "stylesheet" type = "text/css"/>

<Link href = "Style/pagination.css" mce_href = "Style/pagination.css" rel = "stylesheet" type = "text/css"/>

<Script type = "text/javascript">

Var pageIndex = 0; // initial page index value

Var pageSize = 10; // The number of entries displayed on each page is initialized. modify the number of entries displayed. Modify the value here.

$ (Function (){

InitTable (0); // Load event, initialize table data, page index is 0 (first page)

// PageCount indicates the total number of entries. This is a required parameter and other parameters are optional.

$ ("# Pagination"). pagination (<% = pageCount %> ,{

Callback: PageCallback,

Prev_text: 'preput', // text in the previous page button

Next_text: 'Next page', // text in the next pagination button

Items_per_page: pageSize, // Number of display entries

Num_display_entries: 6, // Number of pagination entries in the main part of a consecutive page

Current_page: pageIndex, // index of the current page

Num_edge_entries: 2 // number of entries at the beginning and end of each side

});

// Paging call

Function PageCallback (index, jq ){

InitTable (index );

}

// Request data

Function InitTable (pageIndex ){

$. Ajax ({

Type: "POST ",

DataType: "text ",

Url: 'handler/PagerHandler. ashx', // submit the data to the General processing program request

Data: "pageIndex =" + (pageIndex + 1) + "& pageSize =" + pageSize, // submit two parameters: pageIndex and pageSize)

Success: function (data ){

$ ("# Result tr: gt (0 )"). remove (); // remove the rows in the table whose Id is Result, starting from the second row (this is changed according to the page layout)

$ ("# Result"). append (data); // append the returned data to the table.

}

});

}

});

</Script>

</Head>

<Body>

<Div align = "center">

<H1> Posrchev ---- refreshing pagination

</Div>

<Div id = "container">

<Table id = "Result" cellspacing = "0" cellpadding = "0">

<Tr>

<Th> Number </th>

<Th> name </th>

</Tr>

</Table>

<Div id = "Pagination"> </div>

</Div>

</Body>

</Html>

 

3. Page. cs file content:

Using System;

Using System. Collections. Generic;

Using System. Linq;

Using System. Web;

Using System. Web. UI;

Using System. Web. UI. WebControls;

Public partial class _ Default: System. Web. UI. Page

{

Public string pageCount = string. Empty; // total number of entries

Protected void Page_Load (object sender, EventArgs e)

{

If (! IsPostBack)

{

PageCount = new PagerTestBLL. PersonManager (). GetPersonCount (). ToString ();

}

}

}

 

 

 

4. Content in Handler:

<% @ WebHandler Language = "C #" Class = "PagerHandler" %>

Using System;

Using System. Web;

Using System. Collections. Generic;

Using System. Text;

Public class PagerHandler: IHttpHandler {

Public void ProcessRequest (HttpContext context ){

Context. Response. ContentType = "text/plain ";

String str = string. Empty;

// Page count

Int pageIndex;

Int. TryParse (context. Request ["pageIndex"], out pageIndex );

// Number of entries displayed on the page

Int size = Convert. ToInt32 (context. Request ["pageSize"]);

If (pageIndex = 0)

{

PageIndex = 1;

}

Int count;

List <PagerTestModels. Person> list = new PagerTestBLL. PersonManager (). GetAllPerson (size, pageIndex, "", out count );

StringBuilder sb = new StringBuilder ();

Foreach (PagerTestModels. Person p in list)

{

Sb. Append ("<tr> <td> ");

Sb. Append (p. Id. ToString ());

Sb. Append ("</td> <td> ");

Sb. Append (p. Name );

Sb. Append ("</td> </tr> ");

}

Str = sb. ToString ();

Context. Response. Write (str );

}

 

Public bool IsReusable {

Get {

Return false;

}

}

}

 

5. Implementation:

 

 

6. Source: http://www.bkjia.com/uploadfile/2011/1031/20111031055903284.rar

 

Author porschev

Related Article

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.