关于文章分页
加入一篇几万字的文章,想让他自动分页,Pagesize自己制定
我的文章内容比如是:asoidhsadhasjkdhasjkdas
d
asd
asasdasdasdas
d
asd
sadopgjdfgjdklfgsdasdasda
dfsghasdsadsadasdasda
fhkgfhjklghsdasdasdas
gfh
gf
hfgdasdasdas
hg
fhgfklhkfldasdasdasdasdas
....
我想让他这样
asoidhsadhasjkdhasjkdas
d
asd
asasdasdasdas
d
asd
sadopgjdfgjdklfgsdasdasda
dfsghasdsadsadasdasda
[1] [2] [...]
第二页是
fhkgfhjklghsdasdasdas
gfh
gf
hfgdasdasdas
hg
fhgfklhkfldasdasdasdasdas
....
第[..]页是
....
怎么做到呢?刚刚看了好多材料,不是很明白
请大哥们说说自己的做法吧,小弟这里谢过了^o^
------解决方案--------------------自己学个方法.至于怎么写,我还在进行中.写好了拿来一起研究研究!
------解决方案--------------------通过JS控制吧,写个函数输出,如果字节数到了 或超过多少有换行符时 就分一页,其他隐藏!
------解决方案--------------------好象很难实行精确的分页.
只能通过加入分页码来进行分页吧,如需要分页的时候,插入一特别的字符串<Pager>!
------解决方案--------------------
文章的分页我的方法是加标签,就是在要分页的地方加上分页标签
给个例子你把[code=C#][/code]using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
using System.Text;
public partial class BlogListDetails : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
int id = int.Parse(Request.QueryString["id"].ToString());
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MovieConnectionString"].ToString());
SqlCommand cmd = new SqlCommand();
SqlParameter Sqlid = new SqlParameter("@id", SqlDbType.Int);
Sqlid.Value = id;
cmd.Parameters.Add(Sqlid);
cmd.CommandText = "select BTopic from BlogList where BID=@id";
cmd.Connection = con;
con.Open();
string topic = cmd.ExecuteScalar().ToString();
con.Close();
this.Label1.Text = topic;
string path = "E:\\News\\" + topic + ".txt";
FileStream fs = new FileStream(path, FileMode.Open);
StreamReader sr = new StreamReader(fs, Encoding.GetEncoding("gb2312"));
string content = sr.ReadToEnd();
sr.Dispose();
fs.Dispose();
string[] contentArray = StringSplit(content, "<#####>");
int PageCount = contentArray.Length;
this.lbTotal.Text = "共<b><font color='#FF0000'>" + PageCount.ToString() + "</font></b>页";
int CurPage;
if (System.Web.HttpContext.Current.Request.Params["Page"] != null)
{
CurPage = Convert.ToInt32(System.Web.HttpContext.Current.Request.Params["Page"]);
if (CurPage == 1)
{
this.hplPrv.Enabled = false;
}
}
else
{
CurPage = 1;
this.hplPrv.Enabled = false;
}
if (CurPage < 1) CurPage = 1;
if (Convert.ToInt32(System.Web.HttpContext.Current.Request.Params["Page"]) >= PageCount)
{
CurPage = PageCount;