Asp. NET partial page Refresh page with Ajax implementation

Source: Internet
Author: User

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:listviewID= "Newblogitems"runat= "Server"DataSourceID= "AccessDataSource1"ViewStateMode= "Disabled">             <ItemTemplate>                        <Liclass= "Newblogitem">                          .....                          </Li>               </ItemTemplate> </Asp:listview><Asp:datapagerID= "DataPager1"runat= "Server"PageSize= " the"Pagedcontrolid= "Newblogitems"ViewStateMode= "Disabled">      < Fields>               <Asp:nextpreviouspagerfieldButtonType= "Link"Showfirstpagebutton= "True"Shownextpagebutton= "False"Showpreviouspagebutton= "False" />                <Asp:numericpagerfield/>                 <Asp:nextpreviouspagerfieldButtonType= "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:updatepanelrunat= "Server">   <ContentTemplate>    <%--Data Source--%><Asp:accessdatasourceID= "AccessDataSource1"runat= "Server"datafile= "C:\STORAGE\USERS.ACCDB"SelectCommand= "SELECT [UserName], [Blogtitle], [Blogtime], [Blogurl],[statis] from [blog] ORDER by [Blogtime] DESC"></Asp:accessdatasource><Asp:listviewID= "Newblogitems"runat= "Server"DataSourceID= "AccessDataSource1"ViewStateMode= "Disabled">        <ItemTemplate>             <Liclass= "Newblogitem">1000 words omitted here</Li>          </ItemTemplate></Asp:listview><Asp:datapagerID= "DataPager1"runat= "Server"PageSize= " the"Pagedcontrolid= "Newblogitems"ViewStateMode= "Disabled">    < Fields>         <Asp:nextpreviouspagerfieldButtonType= "Link"Showfirstpagebutton= "True"Shownextpagebutton= "False"Showpreviouspagebutton= "False" />         <Asp:numericpagerfield/>         <Asp:nextpreviouspagerfieldButtonType= "Link"Showlastpagebutton= "True"Shownextpagebutton= "False"Showpreviouspagebutton= "False" />    </ Fields> </Asp:datapager></ContentTemplate> <Triggers>           <Asp:asyncpostbacktriggerControlID= "DataPager1"/> </Triggers> </Asp:updatepanel>

See more code content, welcome to my Independent blog! My blog for this article URL. Home: www.songshizhao.com

Asp. NET partial page Refresh page with Ajax implementation

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.