zoukankan      html  css  js  c++  java
  • AspNetPager + GridView + ASP.NET AJAX 分页无刷新实现

      准备资源:

                  AspNetPager 下载网址:http://www.webdiyer.com/download/default.aspx 

                        ASP.NET AJAX  下载网址:http://www.asp.net/downloads/

            首先,我们应该先了解一下AspNetPager 这个分页工具的工作方式,或者叫有几种分页方法,AspNetPager  官方上说:支持通过Url进行分页,支持PostBack分页,具体二者的区别在:http://www.webdiyer.com/AspNetPager/WhyUrlPaging.aspx 上有详细说明。其实Url 分页就是一个完整的地址后面带一个要跳转的页数,如http://www.XXX.com/XXX/XXX.aspx?page=2 ,而PostBack分页在浏览器状态栏显示如 javascript:__doPostBack('XXX$XXX$XXX','2'),很明显的后台调用方式 。

      知道了分页机制,我们就知道应该选择那种分面机制来和ASP.NET AJAX  搭配比较简单了,就是PostBack 。

    PostBack方式:

    <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="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" 
        ShowPageIndexBox="Always" TextAfterPageIndexBox="页" TextBeforePageIndexBox="转到">
    </webdiyer:AspNetPager>

    Url 重写方式:

    <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="页" TextBeforePageIndexBox="转到" UrlPaging="True">
    </webdiyer:AspNetPager>

    注意两者的一个重要区别:UrlPaging="True"

    剩下的就不用多说了,比如导入ASP.NET AJAX 的引用,但配置web.config 文件时一定要注意,特别是在已建好的项目。搞不好就会让你头疼,最好的做法是,先建一个ASP.NET AJAX的项目,然后将其web.config 的内容复制到你的项目配置文件中,考验你的眼力和耐力,呵呵。页面上就是将GRIDVIEW 和 AspNetPager 放在 asp:UpdatePanel  中就可以了。

    这些只是ASP.NET AJAX 功能的冰山一角,它提供的方法没有用到一个,研究和使用ASP.NET AJAX 一定会让你的WEB项目更丰满。

  • 相关阅读:
    vim实用技巧总结
    configure, make, make install都做了什么
    替换ubuntu 14.04的源
    从源码Build vim以及打包.deb
    Vimperator技巧
    搭建Gitlab
    [转] 你真的会写单例模式吗——Java实现
    笔记本开临时Wifi
    Ubuntu 12.04 修改键盘映射
    oracle查看用户所在的表空间
  • 原文地址:https://www.cnblogs.com/ranran/p/3985881.html
Copyright © 2011-2022 走看看