而且字数是不确定的,所以分页必须是动态的
大家给点思路吧,多谢了
8 个解决方案
#1
顶上去
#2
判断输出的字符串的长度,大于500就分页
#3
一般不是这样分页的吧,基本没有什么意义啊,因为你丛数据库里面取出来以后,就需要截取字长然后放进数组,然后一个控件去读取不同的数组而已
#4
一般不是这样分页的吧,基本没有什么意义啊
======
给手机用户用的,手机上看文章,文章太长的话,就下一页
======
给手机用户用的,手机上看文章,文章太长的话,就下一页
#5
22
#6
ASP的,仅供参考
''''''最简单的长文章自动分页
''''''Power by Love_Computer
''''''http://www.56390.com
''''''love_computer@163.com
''''''2005-9-22
TestStr = "111111111,2222222222222,333333333333,444,555555555,6666666666,777777777,888888,99999999,00000000000000"
'上面这句替换成新闻内容即可
PageLen = 20'每页显示长度
SplitStr = ","'分隔关键字符串
If Len(TestStr) <= PageLen Then
Response.Write TestStr & "<br/>"
Else
str = Split(TestStr,SplitStr)
strShow = ""
Page = Trim(Request.QueryString("page"))
If Page = "" Then page = 1
x = Trim(Request.QueryString("x"))
If x = "" Then
x = 0
Else
x = x + 1
End If
For i = x To ubound(str)-1
strShow = strShow & str(i) & SplitStr
If Len(strShow) > PageLen Then
x = i
Exit For
End If
Next
''''''Power by Love_Computer
''''''love_computer@163.com
''''''2005-9-22
Response.Write strShow & "<br/>"
If Page > 1 Then
Response.Write " <a href='javascript:history.back();'>[上页]</a> "
Else
Response.Write " [上页] "
End If
If x < ubound(str)-1 Then
Response.Write " <a href='?x=" & x & "&page=" & Page + 1 & "'>[下页]</a> "
Else
Response.Write " [下页] "
End If
End If
''''''最简单的长文章自动分页
''''''Power by Love_Computer
''''''http://www.56390.com
''''''love_computer@163.com
''''''2005-9-22
TestStr = "111111111,2222222222222,333333333333,444,555555555,6666666666,777777777,888888,99999999,00000000000000"
'上面这句替换成新闻内容即可
PageLen = 20'每页显示长度
SplitStr = ","'分隔关键字符串
If Len(TestStr) <= PageLen Then
Response.Write TestStr & "<br/>"
Else
str = Split(TestStr,SplitStr)
strShow = ""
Page = Trim(Request.QueryString("page"))
If Page = "" Then page = 1
x = Trim(Request.QueryString("x"))
If x = "" Then
x = 0
Else
x = x + 1
End If
For i = x To ubound(str)-1
strShow = strShow & str(i) & SplitStr
If Len(strShow) > PageLen Then
x = i
Exit For
End If
Next
''''''Power by Love_Computer
''''''love_computer@163.com
''''''2005-9-22
Response.Write strShow & "<br/>"
If Page > 1 Then
Response.Write " <a href='javascript:history.back();'>[上页]</a> "
Else
Response.Write " [上页] "
End If
If x < ubound(str)-1 Then
Response.Write " <a href='?x=" & x & "&page=" & Page + 1 & "'>[下页]</a> "
Else
Response.Write " [下页] "
End If
End If
#7
在一篇文章过长时,可以自动的写个小程序对其进行分页。
具体代码:
public class t3 : System.Web.UI.Page
{
private string str;//字符
private int strl;//字符总长度
private int pagesize;//每页显示的字符数
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
str="1234567891234567898522555";
pagesize=3;
strl=str.Length;
Response.Write(strl);
substr();
}
private void substr()
{
int ct=Int32.Parse(Request.QueryString["page"]);
if(strl==(strl/pagesize)*pagesize)//看看页面的总记录是否能被每页的记录数整除
{
for(int i=1;i<=strl/pagesize;i++)
{
Response.Write("页:<a href=t3.aspx?page="+i +">"+(i)+"</"+"a>");
}
string s=str.Substring(pagesize*ct-pagesize,pagesize);
Response.Write(s);
}
else if(ct*pagesize>strl)//在不被整除的情况下,最后一页的设置,如字符长13,每页3,则处理最后那一页的显示
{
for(int i=1;i<=(strl/pagesize)+1;i++)
{
Response.Write("页:<a href=t3.aspx?page="+i+">"+(i)+"</"+"a>");
}
string s=str.Substring((ct-1)*pagesize,strl-(ct-1)*pagesize);
Response.Write(s);
}
else //在不被整除的情况下其他页面的显示设置
{
for(int i=1;i<=strl/pagesize+1;i++)
{
Response.Write("页:<a href=t3.aspx?page="+i +">"+(i)+"</"+"a>");
}
string s=str.Substring(pagesize*ct-pagesize,pagesize);
Response.Write(s);
}
}
}
具体代码:
public class t3 : System.Web.UI.Page
{
private string str;//字符
private int strl;//字符总长度
private int pagesize;//每页显示的字符数
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
str="1234567891234567898522555";
pagesize=3;
strl=str.Length;
Response.Write(strl);
substr();
}
private void substr()
{
int ct=Int32.Parse(Request.QueryString["page"]);
if(strl==(strl/pagesize)*pagesize)//看看页面的总记录是否能被每页的记录数整除
{
for(int i=1;i<=strl/pagesize;i++)
{
Response.Write("页:<a href=t3.aspx?page="+i +">"+(i)+"</"+"a>");
}
string s=str.Substring(pagesize*ct-pagesize,pagesize);
Response.Write(s);
}
else if(ct*pagesize>strl)//在不被整除的情况下,最后一页的设置,如字符长13,每页3,则处理最后那一页的显示
{
for(int i=1;i<=(strl/pagesize)+1;i++)
{
Response.Write("页:<a href=t3.aspx?page="+i+">"+(i)+"</"+"a>");
}
string s=str.Substring((ct-1)*pagesize,strl-(ct-1)*pagesize);
Response.Write(s);
}
else //在不被整除的情况下其他页面的显示设置
{
for(int i=1;i<=strl/pagesize+1;i++)
{
Response.Write("页:<a href=t3.aspx?page="+i +">"+(i)+"</"+"a>");
}
string s=str.Substring(pagesize*ct-pagesize,pagesize);
Response.Write(s);
}
}
}
#8
http://community.csdn.net/Expert/topic/5313/5313744.xml?temp=.9008905
#1
顶上去
#2
判断输出的字符串的长度,大于500就分页
#3
一般不是这样分页的吧,基本没有什么意义啊,因为你丛数据库里面取出来以后,就需要截取字长然后放进数组,然后一个控件去读取不同的数组而已
#4
一般不是这样分页的吧,基本没有什么意义啊
======
给手机用户用的,手机上看文章,文章太长的话,就下一页
======
给手机用户用的,手机上看文章,文章太长的话,就下一页
#5
22
#6
ASP的,仅供参考
''''''最简单的长文章自动分页
''''''Power by Love_Computer
''''''http://www.56390.com
''''''love_computer@163.com
''''''2005-9-22
TestStr = "111111111,2222222222222,333333333333,444,555555555,6666666666,777777777,888888,99999999,00000000000000"
'上面这句替换成新闻内容即可
PageLen = 20'每页显示长度
SplitStr = ","'分隔关键字符串
If Len(TestStr) <= PageLen Then
Response.Write TestStr & "<br/>"
Else
str = Split(TestStr,SplitStr)
strShow = ""
Page = Trim(Request.QueryString("page"))
If Page = "" Then page = 1
x = Trim(Request.QueryString("x"))
If x = "" Then
x = 0
Else
x = x + 1
End If
For i = x To ubound(str)-1
strShow = strShow & str(i) & SplitStr
If Len(strShow) > PageLen Then
x = i
Exit For
End If
Next
''''''Power by Love_Computer
''''''love_computer@163.com
''''''2005-9-22
Response.Write strShow & "<br/>"
If Page > 1 Then
Response.Write " <a href='javascript:history.back();'>[上页]</a> "
Else
Response.Write " [上页] "
End If
If x < ubound(str)-1 Then
Response.Write " <a href='?x=" & x & "&page=" & Page + 1 & "'>[下页]</a> "
Else
Response.Write " [下页] "
End If
End If
''''''最简单的长文章自动分页
''''''Power by Love_Computer
''''''http://www.56390.com
''''''love_computer@163.com
''''''2005-9-22
TestStr = "111111111,2222222222222,333333333333,444,555555555,6666666666,777777777,888888,99999999,00000000000000"
'上面这句替换成新闻内容即可
PageLen = 20'每页显示长度
SplitStr = ","'分隔关键字符串
If Len(TestStr) <= PageLen Then
Response.Write TestStr & "<br/>"
Else
str = Split(TestStr,SplitStr)
strShow = ""
Page = Trim(Request.QueryString("page"))
If Page = "" Then page = 1
x = Trim(Request.QueryString("x"))
If x = "" Then
x = 0
Else
x = x + 1
End If
For i = x To ubound(str)-1
strShow = strShow & str(i) & SplitStr
If Len(strShow) > PageLen Then
x = i
Exit For
End If
Next
''''''Power by Love_Computer
''''''love_computer@163.com
''''''2005-9-22
Response.Write strShow & "<br/>"
If Page > 1 Then
Response.Write " <a href='javascript:history.back();'>[上页]</a> "
Else
Response.Write " [上页] "
End If
If x < ubound(str)-1 Then
Response.Write " <a href='?x=" & x & "&page=" & Page + 1 & "'>[下页]</a> "
Else
Response.Write " [下页] "
End If
End If
#7
在一篇文章过长时,可以自动的写个小程序对其进行分页。
具体代码:
public class t3 : System.Web.UI.Page
{
private string str;//字符
private int strl;//字符总长度
private int pagesize;//每页显示的字符数
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
str="1234567891234567898522555";
pagesize=3;
strl=str.Length;
Response.Write(strl);
substr();
}
private void substr()
{
int ct=Int32.Parse(Request.QueryString["page"]);
if(strl==(strl/pagesize)*pagesize)//看看页面的总记录是否能被每页的记录数整除
{
for(int i=1;i<=strl/pagesize;i++)
{
Response.Write("页:<a href=t3.aspx?page="+i +">"+(i)+"</"+"a>");
}
string s=str.Substring(pagesize*ct-pagesize,pagesize);
Response.Write(s);
}
else if(ct*pagesize>strl)//在不被整除的情况下,最后一页的设置,如字符长13,每页3,则处理最后那一页的显示
{
for(int i=1;i<=(strl/pagesize)+1;i++)
{
Response.Write("页:<a href=t3.aspx?page="+i+">"+(i)+"</"+"a>");
}
string s=str.Substring((ct-1)*pagesize,strl-(ct-1)*pagesize);
Response.Write(s);
}
else //在不被整除的情况下其他页面的显示设置
{
for(int i=1;i<=strl/pagesize+1;i++)
{
Response.Write("页:<a href=t3.aspx?page="+i +">"+(i)+"</"+"a>");
}
string s=str.Substring(pagesize*ct-pagesize,pagesize);
Response.Write(s);
}
}
}
具体代码:
public class t3 : System.Web.UI.Page
{
private string str;//字符
private int strl;//字符总长度
private int pagesize;//每页显示的字符数
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
str="1234567891234567898522555";
pagesize=3;
strl=str.Length;
Response.Write(strl);
substr();
}
private void substr()
{
int ct=Int32.Parse(Request.QueryString["page"]);
if(strl==(strl/pagesize)*pagesize)//看看页面的总记录是否能被每页的记录数整除
{
for(int i=1;i<=strl/pagesize;i++)
{
Response.Write("页:<a href=t3.aspx?page="+i +">"+(i)+"</"+"a>");
}
string s=str.Substring(pagesize*ct-pagesize,pagesize);
Response.Write(s);
}
else if(ct*pagesize>strl)//在不被整除的情况下,最后一页的设置,如字符长13,每页3,则处理最后那一页的显示
{
for(int i=1;i<=(strl/pagesize)+1;i++)
{
Response.Write("页:<a href=t3.aspx?page="+i+">"+(i)+"</"+"a>");
}
string s=str.Substring((ct-1)*pagesize,strl-(ct-1)*pagesize);
Response.Write(s);
}
else //在不被整除的情况下其他页面的显示设置
{
for(int i=1;i<=strl/pagesize+1;i++)
{
Response.Write("页:<a href=t3.aspx?page="+i +">"+(i)+"</"+"a>");
}
string s=str.Substring(pagesize*ct-pagesize,pagesize);
Response.Write(s);
}
}
}
#8
http://community.csdn.net/Expert/topic/5313/5313744.xml?temp=.9008905