日期:2014-05-20  浏览次数:20377 次

ASP.NET文章分页
如题,很难,小弟不会,能计算字数那种吗

------解决方案--------------------
关注
------解决方案--------------------
有控件的八!
------解决方案--------------------
分太少~
------解决方案--------------------
属性生成器 ,分页》允许分页》选择页数
后台代码就不说了,

------解决方案--------------------
脑筋急转弯呀
------解决方案--------------------
第一页.str.SubString(0,长度)
第二页.str.SubString(长度)
如果要精确点,就在第二页的字符串中找第一个标点,放到第一页去

------解决方案--------------------
兄弟这个问题也困扰了我好久,如果根据字数进行计算那么就要去掉HTML标记,而且不能实现根据段落截断,如果发布的是个excel类似的表格就不行了。所以现在我采用WEBEDITOR的手工插入分页标记进行分页
参考代码如下:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
private string [] split_content;
private string split_str= "[page_break] "; //分页截断字符
private string footPage= " ";
private string id;
private string getPageSize;
private int pagecount; //总页数
private int currentpage; //当前页
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面

if(!this.IsPostBack)
{
id=Request.QueryString[ "newsid "];
getPageSize=Request.QueryString[ "page "];
news=newshdl.getNews(id);
this.l_newstitle.Text=news.getNewstitle();
this.l_newsdate.Text=news.getNewsDate();
this.l_newsauthor.Text=news.getNewsAuthor();
this.l_newssource.Text=news.getNewsSource();
split_content=Regex.Split(news.getNewsContent(),split_str,RegexOptions.IgnoreCase);
pagecount=split_content.Length;

/**
*
* 判断新闻内容是否分页
* */
if(split_content.Length> 1)
{
for(int i=0;i <split_content.Length;i++)
{
currentpage=i+1; //当前页
footPage+= " <a class=pagerTxt href=newsShow.aspx?newsid= "+id+ "&page= "+currentpage+ "> "+currentpage+ "&nbsp;&nbsp; </a> &nbsp;&nbsp; ";
}
if(getPageSize!=null)
footPage+= " <font color=red> "+getPageSize+ " </font> / "+pagecount+ " "; //打印当前页和总页数
else
footPage+= " <font color=red> 1 </font> / "+pagecount+ " "; //打印当前页和总页数
this.l_page.Text=footPage;

}
else
{
this.l_newscontent.Text=news.getNewsContent();
this.l_page.Visible=false;
}

/**
* 判断提交的页码
* */

if(getPageSize!=null) //判断提交的页码
{
this.l_newscontent.Text=split_content[Convert.ToInt32(getPageSize)-1];

}
else
{
this.l_newscontent.Text=split_content[0];

}
}



}
------解决方案--------------------
吴棋娃 分页控件~

http://www.webdiyer.com/

------解决方案--------------------
楼上的,楼主是说新闻内容分页不是列表分页