A detailed example of the code that uses Ajax to partially refresh pages in pagination

Source: Internet
Author: User
The use of Ajax methods to achieve paging is also very simple, mainly two, contenttemplate and trigger. Throw the ListView into the ContentTemplate first. Then add Asp:asyncpostbacktrigger to the trigger and point the ID to the previous paging control DataPager control. Specific implementation of the code can be referred to this article

The ListView list is very easy to implement for paging. The ListView paging is very simple, plus a DataPager control that assigns the ListView ID to it. That's what I wrote at the beginning. (Online people say this is pseudo-paging?) )

<asp:listview id= "Newblogitems" runat= "Server" datasourceid= "AccessDataSource1" viewstatemode= "Disabled" >       <ItemTemplate>            <li class= "Newblogitem" >             ...             .. </li>        </ItemTemplate> </asp:listview><asp:datapager id= "DataPager1" runat= "Server" Pagesize= "pagedcontrolid=" Newblogitems "viewstatemode=" Disabled ">   <Fields>        <asp: Nextpreviouspagerfield buttontype= "Link" showfirstpagebutton= "True" shownextpagebutton= "False" showpreviouspagebutton= "False"/>        <asp:numericpagerfield/>         <asp:nextpreviouspagerfield Buttontype= "Link" showlastpagebutton= "True" shownextpagebutton= "false" showpreviouspagebutton= "false"/>    </Fields></asp:DataPager>

However, to finish this, click on the effect of paging is to refresh the entire page, refresh the page to jump to jump off of course is not friendly, so to update the page, the first thought of the jquery plug-in, so in the online download jpages this plug-in, fiddling with a half-day did not make, also do not know where there are errors ... So abandoned the pit, or Ajax it!

Using the Ajax method, it is easy to pull the elephant into the refrigerator for a total of three steps.

1. Introduce the AJAX control ScriptManager and put it in the form.

2. Introduce the AJAX control UpdatePanel.

3. Edit the UpdatePanel content.

The main is two, ContentTemplate and trigger. Throw the ListView into the ContentTemplate first. Then add Asp:asyncpostbacktrigger to the trigger and point the ID to the previous paging control DataPager control, so that's it. The code is as follows:

<asp:updatepanel runat= "Server" > <ContentTemplate> <%--Data source--%><asp:accessdatasource id= " AccessDataSource1 "runat=" Server "datafile=" C:\storage\users.accdb "selectcommand=" SELECT [UserName], [Blogtitle], [ Blogtime], [Blogurl],[statis] from [blog] ORDER by [Blogtime] DESC "></asp:accessdatasource><asp:listview Id= "Newblogitems" runat= "Server" datasourceid= "AccessDataSource1" viewstatemode= "Disabled" > <itemtemplate > <li class= "Newblogitem" > 1000 words omitted here </li> </itemtemplate></asp:listview><asp  :D atapager id= "DataPager1" runat= "Server" pagesize= "pagedcontrolid=", Newblogitems "viewstatemode=" > <Fields> <asp:nextpreviouspagerfield buttontype= "Link" showfirstpagebutton= "True" shownextpagebutton= " False "showpreviouspagebutton=" false "/> <asp:numericpagerfield/> <asp:nextpreviouspagerfield ButtonT Ype= "Link" showlastpagebutton= "True" shownextpagebutton= "False" Showpreviouspagebutton= "False"/> </Fields> </asp:DataPager></ContentTemplate> <Triggers> & Lt;asp:asyncpostbacktrigger controlid= "DataPager1"/> </Triggers> </asp:UpdatePanel>
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.