ASP.NET中如何将长文章内容分页! 各位高手,请问在ASP.NET中如何将长文章内容分页显示啊!可以给点代码看吗?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下载我写得http://www.mytopwin.com/Soft/ShowSoft/18/14.html看 StringBuilder sb=new StringBuilder(); string temp=this.Label1.Text; string temp_string=this.Label1.Text; int sum=0; int temp_sum=0; int temp_i=0; int flat_add=0; if(temp.IndexOf("<")==-1) { temp=Server.HtmlDecode(temp); temp=temp.Replace(" ",""); temp=temp.Replace("\r\n",""); news.NewsCount=temp.Length; } else { //temp=temp.Replace(" ",""); temp=temp.Replace("\r\n",""); temp=Server.HtmlDecode(temp); //temp=temp.Replace(" ",""); //temp_string=temp_string.Replace(" ",""); temp_string=temp_string.Replace("\r\n",""); temp_string=Server.HtmlDecode(temp_string); //temp_string=temp_string.Replace(" ",""); bool f=temp_string==temp; while(temp.IndexOf("<")!=-1&&temp.LastIndexOf(">")!=-1) { sum+=temp.IndexOf("<"); temp_sum+=temp.IndexOf("<"); int i=Convert.ToInt32(temp.IndexOf("<")+1); int j=Convert.ToInt32(temp.IndexOf(">")+1); int m=Convert.ToInt32(temp[temp.IndexOf("<")+1]); if(((m>=65)&&(m<=122))||temp[temp.IndexOf("<")+1]=='/'||temp[temp.IndexOf("<")+1]==' ') { temp_i+=temp.IndexOf(">")+1; sb.Remove(0,sb.Length); sb.Append(temp); temp=sb.Remove(0,j).ToString(); } else { temp_i+=temp.IndexOf("<")+1; sb.Remove(0,sb.Length); sb.Append(temp); temp=sb.Remove(0,i).ToString(); } if(temp_sum>500) { string s=temp_string[temp_i].ToString(); temp_string=temp_string.Insert(temp_i+flat_add,"$"); flat_add++; temp_sum=0; } } if(sum<700) { temp_string=temp_string.Replace('$',' '); } } news.NewsCount=sum;在该段代码中,通过在某些位置插入特殊字符,是为以后分页显示数据做准备的。如果总字数小于700的话,则不分页,否则每页500字。 解决了,可以参考一下这个!谢谢各位高手啊!http://www.pconline.com.cn/pcjob/process/other/others/0412/513979.html 有谁用过小孔子的CMS2.1 Document 对象的字符串如何过滤 快速.NET网站生成系统软件都有什么好用? .net程序和php discuz论坛的登录整合? .net SQL查询 结果 邮件 updatepanel无刷新页面 求一SQL語句 SQL 触发器 保持唯一的怎么实现啊?~ 请教高手,做什么样的网站最赚钱 C#.Net中创建Web项目报错,急急急!!在线等待................... asp.net生成静态HTML的问题 各位高手帮忙啊!死定了!
http://www.mytopwin.com/Soft/ShowSoft/18/14.html
看
string temp=this.Label1.Text;
string temp_string=this.Label1.Text;
int sum=0;
int temp_sum=0;
int temp_i=0;
int flat_add=0;
if(temp.IndexOf("<")==-1)
{
temp=Server.HtmlDecode(temp);
temp=temp.Replace(" ","");
temp=temp.Replace("\r\n","");
news.NewsCount=temp.Length;
}
else
{
//temp=temp.Replace(" ","");
temp=temp.Replace("\r\n","");
temp=Server.HtmlDecode(temp);
//temp=temp.Replace(" ","");
//temp_string=temp_string.Replace(" ","");
temp_string=temp_string.Replace("\r\n","");
temp_string=Server.HtmlDecode(temp_string);
//temp_string=temp_string.Replace(" ","");
bool f=temp_string==temp;
while(temp.IndexOf("<")!=-1&&temp.LastIndexOf(">")!=-1)
{
sum+=temp.IndexOf("<");
temp_sum+=temp.IndexOf("<");
int i=Convert.ToInt32(temp.IndexOf("<")+1);
int j=Convert.ToInt32(temp.IndexOf(">")+1);
int m=Convert.ToInt32(temp[temp.IndexOf("<")+1]);
if(((m>=65)&&(m<=122))||temp[temp.IndexOf("<")+1]=='/'||temp[temp.IndexOf("<")+1]==' ')
{
temp_i+=temp.IndexOf(">")+1;
sb.Remove(0,sb.Length);
sb.Append(temp);
temp=sb.Remove(0,j).ToString();
}
else
{
temp_i+=temp.IndexOf("<")+1;
sb.Remove(0,sb.Length);
sb.Append(temp);
temp=sb.Remove(0,i).ToString();
}
if(temp_sum>500)
{
string s=temp_string[temp_i].ToString();
temp_string=temp_string.Insert(temp_i+flat_add,"$");
flat_add++;
temp_sum=0;
}
}
if(sum<700)
{
temp_string=temp_string.Replace('$',' ');
}
}
news.NewsCount=sum;
在该段代码中,通过在某些位置插入特殊字符,是为以后分页显示数据做准备的。如果总字数小于700的话,则不分页,否则每页500字。
http://www.pconline.com.cn/pcjob/process/other/others/0412/513979.html