求生成ASP.Net生成静态HTML页(多条新闻)

yangxiuwu 2007-04-06 09:59:32
看过一些,但都是一页的
现在还是很模糊。不太清楚。有没有源代码?如若有请发至bingsueiliuhen2@163.com,急切需要。谢谢
...全文
382 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangxiuwu 2007-06-03
  • 打赏
  • 举报
回复
能不能在详细点啊
syeerzy 2007-04-07
  • 打赏
  • 举报
回复
静态html页面一个就是一页,你分不分页他都是一页

静态页面里你做postback处理?
net_lhb 2007-04-07
  • 打赏
  • 举报
回复
UP!
zyip 2007-04-07
  • 打赏
  • 举报
回复
静态页做搜索的话,使用lucence
sunxw18 2007-04-07
  • 打赏
  • 举报
回复
mark
bzhi268 2007-04-07
  • 打赏
  • 举报
回复
mark
AzureSharp 2007-04-07
  • 打赏
  • 举报
回复
借贴问问题...
静态页面如果要做搜索.怎么做...
XML存或者HTML存的内容.
ztwz 2007-04-06
  • 打赏
  • 举报
回复
mark
wangzhaoli1982 2007-04-06
  • 打赏
  • 举报
回复
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Text;

namespace 自己做分页
{
public class WebForm1 : System.Web.UI.Page
{
private int PageCount;
private int nRecCount;
private int nPage;
private void Page_Load(object sender, System.EventArgs e)
{

PageDisplay();
}
private void PageDisplay()
{
SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter sda = new SqlDataAdapter();
DataSet ds = new DataSet();
DataTable dt = new DataTable();

conn.ConnectionString = "server=.;pwd=sa;uid=sa;database=你的数据库";
cmd.Connection = conn;
cmd.CommandText = "select 新闻 from 新闻表";
sda.SelectCommand = cmd;
sda.Fill(ds,"Em");
dt = ds.Tables[0];


nRecCount = dt.Rows.Count;
StringBuilder sb = new StringBuilder("");

if(nRecCount > 0)
{
PageCount = nRecCount / 10;
if(nRecCount / 10 > 0)
{
PageCount++;
}
if(this.Request.QueryString["page"] == null)
{
nPage = 1;
}
else
{

this.nPage = int.Parse(this.Request.QueryString["page"]);

}if(this.nPage < 1)
{
nPage = 1;
}
if(this.nPage > this.PageCount)
{
this.nPage = this.PageCount;
}

if(nPage == 1)
{
sb.Append("<a href='WebForm1.aspx?page=1'>首页</a>")
.Append("<a href='WebForm1.aspx?page=")
.Append(nPage + 1)
.Append("'>下一页</a>")
.Append("<a href='WebForm1.aspx?page=")
.Append(PageCount)
.Append("'>尾页</a>")
.Append("    页次:")
.Append(nPage.ToString())
.Append("/")
.Append(PageCount.ToString())
.Append("<br>");
}
else
if(nPage == PageCount)
{
sb.Append("<a href='WebForm1.aspx?page=1'>首页</a>")
.Append("<a href='WebForm1.aspx?page=")
.Append(nPage - 1)
.Append("'>上一页</a>")
.Append("<a href='WebForm1.aspx?page=")
.Append(PageCount)
.Append("'>尾页</a>")
.Append("    页次:")
.Append(nPage.ToString())
.Append("/")
.Append(PageCount.ToString())
.Append("<br>");
}
else
{
sb.Append("<a href='WebForm1.aspx?page=1'>首页</a>")
.Append("<a href='WebForm1.aspx?page=")
.Append(nPage - 1)
.Append("'>上一页</a>")
.Append("<a href='WebForm1.aspx?page=")
.Append(nPage + 1)
.Append("'>下一页</a>")
.Append("<a href='WebForm1.aspx?page=")
.Append(PageCount)
.Append("'>尾页</a>")
.Append("    页次:")
.Append(nPage.ToString())
.Append("/")
.Append(PageCount.ToString())
.Append("<br>");
}
this.Response.Write(sb);

int Start = 10 * (nPage -1);
int End = Start + 10 -1;
if(End > nRecCount -1 )
{
End = nRecCount -1;
}
this.Response.Write("<table border ='1' cellpadding = '0' cellspaceing = '0' style = 'bordercollapse:collapse'bordercolor ='#111111' bgcolor = '#ffffff'><tr>");
this.Response.Write("<td>
新闻</td></tr>");

sb.Remove(0,sb.Length);

for(int i = Start; i <= End; i++)
{
sb.Append("<tr>");
for(int j = 0;j < 5;j++)
{
sb.Append("<td>" + dt.Rows[i][j].ToString() + "</td>");
}
sb.Append("</tr>");
}
sb.Append("</table>");
this.Response.Write(sb);
}
conn.Close();
}

#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}

62,046

社区成员

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

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

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

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