现在的位置: 首页 > 综合 > 正文

使用AspNetPager控件多个参数Url重写功能问题

2013年06月21日 ⁄ 综合 ⁄ 共 800字 ⁄ 字号 评论关闭

AspNetPager控件设置简单方便,性能也可以,经常使用AspNetPager来分页,本次使用AspNetPager重写多个参数时,按照控件上的说明

设置URL的重写格式,老是没有传值成功,最后仔细看了AspNetPager控件源码里的帮助文档,才发现除Page以外的参数,设置格式:%参数名%
 
,必须要和原始Url的参数名相同,控件上没特别说明,我正是忽略这点,发了很多时间调试。
再拿个简单的例子说明下:
原始Url:http://www.xxx.com/articlelist.aspx?type=aspnet&page=2
重写Url:http://www.xxx.com/articlelist/aspnet_2.htm
 
下面是aspx页面设置:
 
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="true"  
                PageSize="20" onpagechanging="AspNetPager1_PageChanging" FirstPageText="首页"  
                LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" UrlPaging="True" 
                ShowFirstLast="False" ShowPageIndexBox="Never"  EnableUrlRewriting="True" UrlRewritePattern="/articlelist/%
 
type%_{0}.htm" ></webdiyer:AspNetPager>
 
要注意的是:UrlRewritePattern="/articlelist/%type%_{0}.htm" 规则中的%type%,就是原始Url中的参数名type,设置相同即可。

抱歉!评论已关闭.