咨询电话:186 7916 6165 咨询电话:186 7916 6165 (微信同号)    在线QQ:181796286
NEWS BLOG ·
学无止境
关注开优网络 关注前沿
ASP.NET百度地图API使用
ASP.NE Excel 数据导入导出

AspNetPager 伪静态设置

发表日期:2016-01-23    文章编辑:南昌开优网络    浏览次数:3847    标签:ASP.NET应用

1、不带参数的分页  使用 原本方即可
<webdiyer:aspnetpager id="anp" runat="server" cssclass="pages" currentpagebuttonclass="cpb"
              custominfohtml="总共%RecordCount%条记录,当前为%CurrentPageIndex%/%PageCount%页" firstpagetext="首页"
              lastpagetext="尾页" nextpagetext="下一页" numericbuttoncount="5" onpagechanged="anp_PageChanged"
              pageindexboxtype="DropDownList" prevpagetext="上一页" showcustominfosection="Left"
              showmorebuttons="False" showpageindexbox="Always" submitbuttontext="Go" textafterpageindexbox="页"
              textbeforepageindexbox="转到">
</webdiyer:aspnetpager>

2、带参数的分页
<webdiyer:aspnetpager id="anp" runat="server" cssclass="pages" currentpagebuttonclass="cpb"
              custominfohtml="总共%RecordCount%条记录,当前为%CurrentPageIndex%/%PageCount%页" firstpagetext="首页"
              lastpagetext="尾页" nextpagetext="下一页" numericbuttoncount="5" onpagechanged="anp_PageChanged"
              pageindexboxtype="DropDownList" prevpagetext="上一页" showcustominfosection="Left"
              showmorebuttons="False" showpageindexbox="Always" submitbuttontext="Go" textafterpageindexbox="页"
              textbeforepageindexbox="转到" PageSize="6" UrlPaging="true"
              EnableUrlRewriting="True" UrlRewritePattern="~/product_%caid%_{0}.html">
    </webdiyer:aspnetpager>
UrlPaging="true"  //开启url参数分页 使用该属性 返回如 news.aspx?caid=1&page=2
EnableUrlRewriting="True"  //开启URL重写
UrlRewritePattern="~/product_%caid%_{0}.html"  //重写规则  %% 为参数可使用多个  {0} 为页数

在Web.config 中配置 伪静态规则
<RewriterRule> 
      <name>产品列表 带分页</name>
      <LookFor>~/product_(\d+)_(\d+).html</LookFor>  //转向
      <SendTo>~/product.aspx?caid=$1&amp;page=$2</SendTo>  //原文件  $1 为第一个参数  $2 为页数
</RewriterRule>