AspNetPager + GridView + ASP. net ajax without refreshing pages,

Source: Internet
Author: User

AspNetPager + GridView + ASP. net ajax without refreshing pages,

Prepare resources:

AspNetPager download link: http://www.webdiyer.com/download/default.aspx

ASP. net ajax download URL: http://www.asp.net/downloads/

 

First, let's take a look at the working method of the AspNetPager paging tool, or several paging methods. The AspNetPager official website says: pagination through URLs and PostBack paging are supported, the specific difference between the two in: http://www.webdiyer.com/AspNetPager/WhyUrlPaging.aspx has a detailed description. In fact, the Url page is a complete address followed by a jump to the number of pages, such as http://www.XXX.com/XXX/XXX.aspx? Page = 2, while the PostBack page is displayed in the browser status bar, such as javascript :__ doPostBack ('xxx $ XXX $ XXX', '2'). The background call method is obvious.

When we know the paging mechanism, we know that we should select the faceted mechanism to make it easier to match ASP. net ajax, that is, PostBack.

PostBack mode:

<Webdiyer: AspNetPager id = "AspNetPager1" runat = "server" PageSize = "10" NumericButtonCount = "10"
ShowCustomInfoSection = "left" PagingButtonSpacing = "0" AlwaysShow = "true" ShowDisabledButtons = "false"
CssClass = "pager_css" HorizontalAlign = "right" SubmitButtonText = "Go" ShowMoreButtons = "true"
NumericButtonTextFormatString = "[{0}]" OnPageChanged = "AspNetPager1_PageChanged" CurrentPageButtonPosition = "Beginning"
FirstPageText = "Homepage" LastPageText = "last page" NextPageText = "next page" PrevPageText = "Previous Page"
ShowPageIndexBox = "Always" TextAfterPageIndexBox = "page" TextBeforePageIndexBox = "go to">
</Webdiyer: AspNetPager>

Url rewriting method:

<Webdiyer: AspNetPager id = "AspNetPager1" runat = "server" PageSize = "10" NumericButtonCount = "10"
ShowCustomInfoSection = "left" PagingButtonSpacing = "0" AlwaysShow = "true" ShowDisabledButtons = "false"
CssClass = "pager_css" HorizontalAlign = "right" SubmitButtonText = "Go" ShowMoreButtons = "true"
NumericButtonTextFormatString = "[{0}]" OnPageChanged = "AspNetPager1_PageChanged" CurrentPageButtonPosition = "Beginning"
PagingButtonLayoutType = "Span" ShowPageIndexBox = "Always" TextAfterPageIndexBox = "page" TextBeforePageIndexBox = "go to" UrlPaging = "True">
</Webdiyer: AspNetPager>

 

Note one important difference between the two: UrlPaging = "True"

 

You don't need to talk about the rest. For example, import the reference of ASP. net ajax, but pay attention to it When configuring the web. config file, especially for the projects that have been created. If it is not done, it will cause you a headache. The best practice is to create an ASP first. net ajax project, and then set its web. copy the config content to your project configuration file to test your eyesight and endurance. On the page, put the GRIDVIEW and AspNetPager in asp: UpdatePanel.

These are just the tip of the ASP. net ajax function. The methods provided by ASP. net ajax are not used. The research and use of ASP. net ajax will surely enrich your WEB project.


Aspnet does not refresh the page with the gridview. It is urgent to use ajax.

//************************************** ******************
// Ajax paging of the AspNetPager Control
//************************************** ******************

// Bind a page number event
Function InitPage (){

// Process the paging Control
$ ("# AspNetPager1"). children ("a"). each (function (){
If ($ (this). attr ("href ")! = ""){
// Obtain the hyperlink of the paging button
Var link = $ (this). attr ("href ");
$ (This). click (function (){
Pages (link );
Return false;
});
}

});
}

// Reset the page content
Function pages (link ){
$. Ajax ({
Type: "post ",
Url: link,
Async: false,
Data: {r: Math. random ()},
Global: false,
Success: function (msg ){
$ ("# List" cmd.html ($ (msg). find ("# list" cmd.html ());
}
});
InitPage ();
}
 
Q: Why is the aspnetpager paging control not displayed after the query data is displayed in the Gridview in VS2005?

In the front-end GridView, AllowPaging is set to TRUE. Now that you have written PageIndexChanging, check whether (right-click -- attribute -- event) there is a choice !!
 

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.