AspNetPager 新闻内容分页
2013-05-13 14:16
309 查看
前台:
<%if (YesIsNoPage)
{%>
<webdiyer:AspNetPager ID="AspNetPager" CssClass="paginator" CurrentPageButtonClass="cpb"
runat="server" AlwaysShow="True" FirstPageText="Home" LastPageText="End" NextPageText="Next"
PageSize="1" PrevPageText="Previous" OnPageChanged="AspNetPager_PageChanged"
CustomInfoTextAlign="Center" LayoutType="Table" ShowPageIndex="false" CustomInfoHTML="Current: %CurrentPageIndex%/%PageCount% Pages"
PageIndexBoxType="TextBox" ShowCustomInfoSection="Left" ShowPageIndexBox="Never">
</webdiyer:AspNetPager>
<% } %>
后台:
protected static string ProductsText;
protected static bool YesIsNoPage;
protected static string strContent;
protected void Products_load()
{
string text = ProductsText;
//查找分页符并替换html标签
string StringB = "<div style=\"page-break-after: always\"> <br /> <span style=\"display: none;\"> </span></div>"; text = text.Replace("\n\t", "");
text = text.Replace("\n", "<br />");
text = text.Replace("\r", " ");
string[] strLined = text.Split(new string[] { StringB }, StringSplitOptions.RemoveEmptyEntries);
string tempString = null;
this.AspNetPager.RecordCount = strLined.Length;
int PageSize = this.AspNetPager.PageSize;
int PageIndex = this.AspNetPager.CurrentPageIndex;
//判断是否显示分页控件
if (strLined.Length > 1)
YesIsNoPage = true;
else
YesIsNoPage = false;
//判断是否启动分页
int JudgeYesPage = strLined.Length / PageSize + 1;
int JudgeNoPage = strLined.Length;
if (this.AspNetPager.CurrentPageIndex != JudgeYesPage)
{
for (int i = (PageIndex - 1) * PageSize; i < PageSize * PageIndex; i++)
{
tempString += strLined[i] + "<br />";
}
strContent = tempString;
}
else
{
for (int i = (PageIndex - 1) * PageSize; i < JudgeNoPage; i++)
{
tempString += strLined[i] + "<br />";
}
strContent = tempString;
}
}
protected void AspNetPager_PageChanged(object sender, EventArgs e)
{
Products_load();
}
<%if (YesIsNoPage)
{%>
<webdiyer:AspNetPager ID="AspNetPager" CssClass="paginator" CurrentPageButtonClass="cpb"
runat="server" AlwaysShow="True" FirstPageText="Home" LastPageText="End" NextPageText="Next"
PageSize="1" PrevPageText="Previous" OnPageChanged="AspNetPager_PageChanged"
CustomInfoTextAlign="Center" LayoutType="Table" ShowPageIndex="false" CustomInfoHTML="Current: %CurrentPageIndex%/%PageCount% Pages"
PageIndexBoxType="TextBox" ShowCustomInfoSection="Left" ShowPageIndexBox="Never">
</webdiyer:AspNetPager>
<% } %>
后台:
protected static string ProductsText;
protected static bool YesIsNoPage;
protected static string strContent;
protected void Products_load()
{
string text = ProductsText;
//查找分页符并替换html标签
string StringB = "<div style=\"page-break-after: always\"> <br /> <span style=\"display: none;\"> </span></div>"; text = text.Replace("\n\t", "");
text = text.Replace("\n", "<br />");
text = text.Replace("\r", " ");
string[] strLined = text.Split(new string[] { StringB }, StringSplitOptions.RemoveEmptyEntries);
string tempString = null;
this.AspNetPager.RecordCount = strLined.Length;
int PageSize = this.AspNetPager.PageSize;
int PageIndex = this.AspNetPager.CurrentPageIndex;
//判断是否显示分页控件
if (strLined.Length > 1)
YesIsNoPage = true;
else
YesIsNoPage = false;
//判断是否启动分页
int JudgeYesPage = strLined.Length / PageSize + 1;
int JudgeNoPage = strLined.Length;
if (this.AspNetPager.CurrentPageIndex != JudgeYesPage)
{
for (int i = (PageIndex - 1) * PageSize; i < PageSize * PageIndex; i++)
{
tempString += strLined[i] + "<br />";
}
strContent = tempString;
}
else
{
for (int i = (PageIndex - 1) * PageSize; i < JudgeNoPage; i++)
{
tempString += strLined[i] + "<br />";
}
strContent = tempString;
}
}
protected void AspNetPager_PageChanged(object sender, EventArgs e)
{
Products_load();
}
相关文章推荐
- AspNetPager+Ajax实现无刷新分页
- AspNetPager 分页 用法
- 在asp.net中长内容自动分页的实现-.NET教程
- 新闻内容实现分页
- 2009.10月15ASP中新闻标题太长时,省略号显示过长内容
- 新闻内容页分页的简单做法
- asp.net文章内容分页方法
- 一步步打造基于ASP.NET的CMS内容管理系统--Step3 添加新闻页面
- AspNetPager分页常见属性
- 用Asp获取Dll加密新闻内容
- C# ASP.NET AspNetPager对DataList控件分页
- 在asp.net中长内容自动分页的实现
- ASP长文章内容自动分页函数
- 突然想要做个新闻内容的分页,网上查了下资料,找到了一个可以用的类(代码需要自己研究下,我已经试验成功了)
- AspNetPager 对数据集合的分页
- AspNetPager分页控件
- DataList编辑、更新、取消、删除、分页(分页控件 AspNetPager.dll)
- AspNetPager分页实例
- [ 急AspNetPager DataList 分页问题]关于分页问题,提问的的确不少,本不想发的,因为有例子,这里奉献给初学[WEB学习实例]
- AspNetPager分页控件