高分求解 有分页的aspx页面如何生成静态页面?
http://topic.csdn.net/u/20080521/14/4940a828-e2e7-44b1-a592-de4f59a23e56.html?seed=1701902541
上面是原帖。
现在用的方法似乎不能有效地生成分页导航栏。看来要换个思路来解决了。在此求方法。
[解决办法]
友情帮顶
[解决办法]
我是我以前写的生成静态页面的方法(包括了分页)
/// <summary> /// 生成栏目静态页面 /// </summary> /// <param name="info">栏目名称,如果要生成首页,为null</param> /// <returns></returns> public bool GerChannelHtmlForEach(ChannelInfo info) { string strShortening, pattern; int countMatch; string strContent = string.Empty; string strTitle = string.Empty; if (info == null||info.ExtUrl.Length < 1) { TemplateInfo tinfo = new TemplateInfo(); BTemplate temp = new BTemplate(); if (info == null) { tinfo.TName = "首页模板"; strTitle = Config.WebSiteTitle + " - 首页"; }else { /*获取模板内容*/ tinfo.Tid = info.TemplateID; strTitle = GetTitleStringForPage(info); } strContent += GetHeadHTML(); strContent += temp.GetTempInfo(tinfo).TContent; strContent += GetFooterHTML(); /*页面标题*/ pattern = @"\{\$WUYOUPAGETITLE\$\}"; countMatch = GetMatchCount(pattern, strContent); for (int index = 0; index < countMatch; index++) { strContent = GetMatchString(pattern, strContent, strTitle); } Channel channel = new Channel(); ChannelInfo pinfo = new ChannelInfo(); ; if(info != null) { pinfo = info; } DataTable dtChannel = channel.GetChannelList(pinfo); foreach (DataRow dr in dtChannel.Rows) { ChannelInfo theinfo = new ChannelInfo(); theinfo.Cid = new Guid(dr["Cid"].ToString()); theinfo = channel.GetChannelInfo(theinfo); /************************************************************************/ /* 声明,标签以List结尾的一般都需要加参数 ",数字"一个标点逗号和一个数字(英语数字) /************************************************************************/ //{$WUYOUXWDTList,3$} //生成文字新闻 strShortening = theinfo.ChannelShortening.ToString().ToUpper(); pattern = @"\{\$WUYOU" + strShortening + @"List,(?<ListCount>\d*)\$\}"; strContent = GetReplaceString(strContent, pattern, theinfo); //{$WUYOUIMGXWDT$} //生成图片新闻 pattern = @"\{\$WUYOUIMG" + strShortening + @"List,(?<ListCount>\d*)\$\}"; strContent = GetMacthIMGString(pattern, strContent, theinfo); //{$WUYOUIMGXWDTTopList,4$} //生成推荐图片新闻 pattern = @"\{\$WUYOUIMG" + strShortening + @"TopList,(?<ListCount>\d*)\$\}"; strContent = GetMacthIMGString(pattern, strContent, theinfo,true); //子栏目下的图片和文字新闻 ChannelInfo ainfo = new ChannelInfo(); ainfo.ParentID = theinfo.Cid; DataTable subChannel = new Channel().GetChannelList(ainfo); if (subChannel.Rows.Count > 0) { foreach (DataRow dri in subChannel.Rows) { ChannelInfo subinfo = new ChannelInfo(); subinfo.Cid = new Guid(dri["Cid"].ToString()); subinfo = new Channel().GetChannelInfo(subinfo); string sstrShortening = subinfo.ChannelShortening.ToUpper(); //文字新闻 string spattern = @"\{\$WUYOU" + sstrShortening + @"List,(?<ListCount>\d*)\$\}"; strContent = GetReplaceString(strContent,spattern, subinfo); //生成图片新闻 spattern = @"\{\$WUYOUIMG" + sstrShortening + @"List,(?<ListCount>\d*)\$\}"; strContent = GetMacthIMGString(spattern, strContent, subinfo); //生成推荐图片新闻 pattern = @"\{\$WUYOUIMG" + strShortening + @"TopList,(?<ListCount>\d*)\$\}"; strContent = GetMacthIMGString(pattern, strContent, theinfo, true); } } /*系统菜单*/ pattern = @"\{\$WUYOUTOPMENU\$\}"; countMatch = GetMatchCount(pattern, strContent); for (int index = 0; index < countMatch; index++) { strContent = GetMatchString(pattern, strContent, GetChannelMenuString(new ChannelInfo(),true)); } /*栏目标题*/ pattern = @"\{\$WUYOUCHANTITLE\$\}"; countMatch = GetMatchCount(pattern, strContent); for (int index = 0; index < countMatch; index++) { strContent = GetMatchString(pattern, strContent, theinfo.ChannelTitle); } /*相关栏目*/ pattern = @"\{\$WUYOUAboutChannel\$\}"; countMatch = GetMatchCount(pattern, strContent); for (int index = 0; index < countMatch; index++) { strContent = GetMatchString(pattern, strContent, GetChannelListString(theinfo)); } /*栏目导航{$WUYOUCHANNAV$}*/ pattern = @"\{\$WUYOUCHANNAV\$\}"; countMatch = GetMatchCount(pattern, strContent); for (int index = 0; index < countMatch; index++) { strContent = GetMatchString(pattern, strContent, GetChannelNav(theinfo, null)); } /*投票系统{$WUYOUVote$}*/ pattern = @"\{\$WUYOUVOTE\$\}"; countMatch = GetMatchCount(pattern, strContent); for (int index = 0; index < countMatch; index++) { strContent = GetMatchString(pattern, strContent, GetVoteString()); } /*单页面内容部分*/ pattern = @"\{\$WUYOUSIMPCONTENT\$\}"; countMatch = GetMatchCount(pattern, strContent); for (int index = 0; index < countMatch; index++) { strContent = GetMatchString(pattern, strContent, GetSimplexContentString(theinfo)); }
[解决办法]
count = count % pagesize > 0 ? count / pagesize + 1 : count / pagesize;
先计算出页数来,
string str = GetNewsListString(theinfo, pagesize, i + 1);
再获取指定页数的内容。
GetPagerString(count, i+1, pagesize,"");
生成页面导航。
CreatePage(strVirPath, strContent);
生成静态页面。
关于生成页面导航的代码,稍后贴出。
我这儿只是提供一个思路,你不必非和我设计的一样,再说,这也是以前写的,现在写的话,可能会更清晰一些。
至于效果,你可以去http://www.wuyou.com.cn上看一下有分页的栏目。
[解决办法]
留个邮箱.我给你发个简单的例子
[解决办法]
up
[解决办法]
牛XX
来一份 哈!!! 谢谢
学习了!
[解决办法]
模板页呢
[解决办法]
hfb030@126.COM
谢谢