ASP. NET uses ajax to implement partial page refreshing and ajax page Functions

Source: Internet
Author: User

ASP. NET uses ajax to implement partial page refreshing and ajax page Functions

It is very easy to implement pagination in the listview list. The pagination of ListView is very simple. Add a DataPager control and grant the ListView ID. This is what I wrote at the beginning. (Some people say this is a pseudo-Paging on the Internet ?)

<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="15" 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, after this writing, the effect of clicking the page is to refresh the entire page. After refreshing, the page is not friendly. Therefore, to partially update the page, I first thought of the jquery plug-in, so I downloaded the JPAGES plug-in on the Internet, and it was not completed after a long time. I don't know where the error was... So let's get rid of it. ajax is the best choice !.

The ajax method is easy to pull. There are three steps to install an elephant in the refrigerator.

1. Introduce the ajax control scriptManager and place it in form.

2. Introduce the ajax control UpdatePanel.

3. Edit the UpdatePanel content.

There are two main types: ContentTemplate and Trigger. First, throw the listView into the ContentTemplate. Add asp: AsyncPostBackTrigger to the Trigger and point the ID to the DataPager control of the previous paging control. The Code is as follows:

<Asp: UpdatePanel runat = "server"> <ContentTemplate> <% -- data source -- %> <asp: AccessDataSource ID = "accessperformance1" 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" performanceid = "accessperformance1" ViewStateMode = "Disabled"> <ItemTemplate> <li class = "newBlogItem"> 1000 words are omitted here </li> </ItemTemplate> </asp: listView> <asp: DataPager ID = "DataPager1" runat = "server" PageSize = "15" 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> </ContentTemplate> <Triggers> <asp: AsyncPostBackTrigger ControlID = "DataPager1"/> </Triggers> </asp: UpdatePanel>

The above is a small series of ASP. NET Using ajax to implement partial page refresh page function, hope to help everyone, if you have any questions, please leave a message, xiaobian will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.