各位高手,请问在ASP.NET中如何将长文章内容分页显示啊!可以给点代码看吗?谢谢!

解决方案 »

  1.   

    下载我写得
    http://www.mytopwin.com/Soft/ShowSoft/18/14.html
      

  2.   

    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("&nbsp;","");
    temp=temp.Replace("\r\n","");
    news.NewsCount=temp.Length;
    }
    else
    {
    //temp=temp.Replace("&nbsp;","");
    temp=temp.Replace("\r\n","");
    temp=Server.HtmlDecode(temp);
    //temp=temp.Replace(" ","");
    //temp_string=temp_string.Replace("&nbsp;","");
    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字。
      

  3.   

    解决了,可以参考一下这个!谢谢各位高手啊!
    http://www.pconline.com.cn/pcjob/process/other/others/0412/513979.html