请教高手们一个问题

wylovemzc 2008-10-31 01:46:12
我现在用lable显示文章内容,但是文章太长了,需要分页显示,我该如何来做啊?
谢谢高手指点,最好有源码,谢谢
我的邮箱wsh3360@sina.com
...全文
31 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jhdxhj 2008-10-31
  • 打赏
  • 举报
回复
我把用literal这个控件来实现的代码发给你:
string strTextCh = "";
string strTextEn = "";


string strSel1 = "SELECT * FROM hotelinformation order by CreateTime desc limit 1";
MyDB db1 = new MyDB(this.Page);
MySqlDataReader dr1 = null;
try
{
dr1 = db1.SelectToReader(strSel1, null);
while (dr1.Read())
{

strTextCh = dr1["HotelIntroduce1"].ToString();
strTextEn = dr1["HotelIntroduce2"].ToString();
strTextCh = "<font face=\"黑体\" color=\"#000000\" size =\"5pt\">" + strTextCh + "</font>";
strTextEn = "<b><font face=\"Arial\" color=\"#000000\" size =\"5pt\">" + strTextEn + "</font></b>";
this.linfo.Text = strTextCh + "<p>    " + strTextEn + "</p>";

}
}
catch
{
}
finally
{
if (dr1 != null)
dr1.Close();
db1.CloseCon();
}
这是部分代码,就是怎么搞的
jhdxhj 2008-10-31
  • 打赏
  • 举报
回复
你可以用literal这个控件来实现很方便
wylovemzc 2008-10-31
  • 打赏
  • 举报
回复
我是从后台录入文字文章,全是文字,好长的,然后前台页面用lable接收
atpains 2008-10-31
  • 打赏
  • 举报
回复
这需要看文章内容具体什么东西。

如果是 纯文本,那就 数字,一页显示多少个字,一路数过来哦。

这没我也没做过,参考一下这段代码


/// <summary>
/// 获得字符的长度
/// </summary>
public static int GetStringLength(string str)
{
byte[] bytes=Encoding.Default.GetBytes(str);
return bytes.Length;
}
/// <summary>
/// 获得指定字符串的长度字符串
/// </summary>
/// <param name="connectingStr">字符串</param>
/// <param name="connectingStr">获得字符的字节数</param>
/// <returns>返回指定长度的字符串,"1234按",长度为4时返回"1234",为5时返回"1234"</returns>
public static string GetStringLength(string strOld,int intCount)
{
char[] chrSingle = strOld.ToCharArray ();
string strNew = string.Empty ;
int intNewCount = 0;
int intTemp = 0;
string strNewTemp =string.Empty ;
foreach(char chrTemp in chrSingle)
{
if (GetStringLength(chrTemp.ToString())==1)
{
strNewTemp = strNew;
strNew +=chrTemp;
intNewCount += 1;
intTemp = 1;
}
else if (GetStringLength(chrTemp.ToString ())==2)
{
strNewTemp = strNew;
strNew +=chrTemp;
intNewCount += 2;
intTemp = 2;
}
if ( intNewCount > intCount-1 )
{
if (intTemp == 2)
{
return strNewTemp;
}
return strNew;
}
}
return strNew;
}



如果 是 HTML文本,一般的做法是 在线编辑器里,插入 分页符,分页符就是一段格式的代码 如:“<div>xxxxxxxxxxxxxxxxxxxxxx</div>”,

提交 表单是,获取在线编辑器的文本后,

String.Split(“<div>xxxxxxxxxxxxxxxxxxxxxx</div>”)

返回 String 数组。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧