亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

ASP.NET使用ajax實(shí)現(xiàn)分頁(yè)局部刷新頁(yè)面功能

 更新時(shí)間:2017年03月23日 08:39:21   投稿:mrr  
使用ajax方法實(shí)現(xiàn)分頁(yè)也很簡(jiǎn)單,主要是兩個(gè),ContentTemplate和Trigger。先把listView扔ContentTemplate里面。然后在Trigger里面加入asp:AsyncPostBackTrigger,將ID指向之前的分頁(yè)控件DataPager控件。具體實(shí)現(xiàn)代碼大家可以參考下本文

  listview列表實(shí)現(xiàn)分頁(yè)是非常容易的。ListView分頁(yè)是非常簡(jiǎn)單的,加上一個(gè)DataPager控件,把ListView的ID賦予就可以了。最開(kāi)始我就是這么寫(xiě)的。(網(wǎng)上有人說(shuō)這樣是偽分頁(yè)?)

<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>

    然而這樣寫(xiě)完,點(diǎn)擊分頁(yè)的效果是刷新整個(gè)頁(yè)面,刷新后頁(yè)面跳來(lái)跳去當(dāng)然是不友好的,所以要局部更新頁(yè)面,最開(kāi)始就想到了jquery插件,于是在網(wǎng)上下載了JPAGES這個(gè)插件,擺弄了半天也沒(méi)弄成,也不知道哪里有錯(cuò)誤。。。于是棄坑了,還是ajax吧!。

   使用ajax方法就很簡(jiǎn)單拉,把大象裝冰箱總共分三步。

1.引入ajax控件ScriptManager,放在form里。

2.引入ajax控件UpdatePanel。

3.編輯UpdatePanel內(nèi)容。

   主要是兩個(gè),ContentTemplate和Trigger。先把listView扔ContentTemplate里面。然后在Trigger里面加入asp:AsyncPostBackTrigger,將ID指向之前的分頁(yè)控件DataPager控件,這樣就可以了。代碼如下:

<asp:UpdatePanel runat="server">
  <ContentTemplate>
  <%--數(shù)據(jù)源--%>
<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字
       </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>

以上所述是小編給大家介紹的ASP.NET使用ajax實(shí)現(xiàn)分頁(yè)局部刷新頁(yè)面功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論