修改AspNetPager的CustomInfoHTML,添加自定义样式

  AspNetPager控件有一个属性叫CustomInfoHTML,可以把它写在前台页面,如下:

<webdiyer:AspNetPager ID="AspNetPager1" runat="server" PageSize="10" 
            HorizontalAlign="right" Width="100%" 
            Style="font-size: 14px"
            AlwaysShow="true" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" 
            PrevPageText="上一页" SubmitButtonText="Go"  SubmitButtonClass="submitBtn"
            CustomInfoStyle="font-size:14px;text-align:left;" 
            InputBoxStyle="width:25px; border:1px solid #999999; text-align:center; " 
            TextBeforeInputBox="转到第" TextAfterInputBox="" PageIndexBoxType="TextBox" 
            ShowPageIndexBox="Always" TextAfterPageIndexBox="" 
            TextBeforePageIndexBox="转到" Font-Size="14px" 
            ShowCustomInfoSection="Left" CustomInfoSectionWidth="19%" 
            PagingButtonSpacing="3px" 

CustomInfoHTML = "<div style='white-space: nowrap'>共<font color='#ff0000'>%PageCount%</font>页,第<font color='#ff0000'>%CurrentPageIndex%</font>页,共<font color='#ff0000'>%RecordCount%</font>宗</div>"

onpagechanged="AspNetPager1_PageChanged">
</webdiyer:AspNetPager>

如果你还想添加一起其他的东西,那么可以在后台单独设置设这个属性,如下:

            AspNetPager1.CustomInfoHTML = "<div style='white-space: nowrap'>共<font color='#ff0000'>%PageCount%</font>页,第<font color='#ff0000'>%CurrentPageIndex%</font>页,共<font color='#ff0000'>%RecordCount%</font>宗,"
               + "总面积为<font color='#ff0000'>" + GetTotalArea() + "</font>平方米</div>";

此处我调用了GetTotalArea()方法。

posted @ 2014-06-17 11:09  金河  阅读(2309)  评论(0编辑  收藏  举报