`
luyou3415
  • 浏览: 57884 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

ASP·NET头条新闻显示功能详解

 
阅读更多

运行效果:

前台代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TopNews222.aspx.cs" Inherits="web.TopNews222" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>头条新闻</title>
<!-- 图片滚动 -->
<SCRIPT language="javascript">
var nn;
nn=2;
setTimeout('change_img()',4000);
function change_img()
{
if(nn>5) nn=1
setTimeout('setFocus1('+nn+')',4000);
nn++;
tt=setTimeout('change_img()',4000);
}
function setFocus1(i)
{
selectLayer1(i);
}
function selectLayer1(i)
{
switch(i)
{
case 1:
document.getElementById("focusPic1").style.display="block";
document.getElementById("focusPic2").style.display="none";
document.getElementById("focusPic3").style.display="none";
document.getElementById("focusPic4").style.display="none";
document.getElementById("focusPic5").style.display="none";
break;
case 2:
document.getElementById("focusPic1").style.display="none";
document.getElementById("focusPic2").style.display="block";
document.getElementById("focusPic3").style.display="none";
document.getElementById("focusPic4").style.display="none";
document.getElementById("focusPic5").style.display="none";
break;
case 3:
document.getElementById("focusPic1").style.display="none";
document.getElementById("focusPic2").style.display="none";
document.getElementById("focusPic3").style.display="block";
document.getElementById("focusPic4").style.display="none";
document.getElementById("focusPic5").style.display="none";
break;
case 4:
document.getElementById("focusPic1").style.display="none";
document.getElementById("focusPic2").style.display="none";
document.getElementById("focusPic3").style.display="none";
document.getElementById("focusPic4").style.display="block";
document.getElementById("focusPic5").style.display="none";
break;
case 5:
document.getElementById("focusPic1").style.display="none";
document.getElementById("focusPic2").style.display="none";
document.getElementById("focusPic3").style.display="none";
document.getElementById("focusPic4").style.display="none";
document.getElementById("focusPic5").style.display="block";
break;
}
}
</SCRIPT>
</head>
<body>
<table style="BORDER-RIGHT: #9ec9eb 1px solid; BORDER-TOP: #9ec9eb 1px solid; BORDER-LEFT: #9ec9eb 1px solid; BORDER-BOTTOM: #9ec9eb 1px solid"
height="434" width="611">
<tr>
<td>
<DIV id="ImgChangeMain">
<DIV id="focusPic1" style="DISPLAY: block"><A href="TopNews.aspx?TopId=1" target="_blank"><IMG height="369" src="topImg/1.jpg" width="611" border="0"></A>
<TABLE style="CLEAR: both; MARGIN: auto" cellSpacing="1" cellPadding="0" width="98%" align="right"
border="0">
<TBODY>
<TR align="center" bgColor="#9ec9ec">
<TD bgColor="#e2eaf7">&nbsp;</TD>
<TD style="COLOR: #ffffff" width="26" bgColor="#0049a5">1</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(2)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">2</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(3)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">3</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(4)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">4</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(5)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">5</TD>
</TR>
</TBODY>
</TABLE>
</DIV>
<DIV class="ImgChange1" id="focusPic2" style="DISPLAY: none"><A href="TopNews.aspx?TopId=2" target="_blank"><IMG height="369" src="topImg/2.jpg" width="611" border="0"></A>
<TABLE style="CLEAR: both; MARGIN: auto" cellSpacing="1" cellPadding="0" width="98%" align="right"
border="0">
<TBODY>
<TR align="center" bgColor="#9ec9ec">
<TD bgColor="#e2eaf7">&nbsp;</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(1)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">1</TD>
<TD style="COLOR: #ffffff" width="26" bgColor="#0049a5">2</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(3)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">3</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(4)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">4</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(5)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">5</TD>
</TR>
</TBODY>
</TABLE>
</DIV>
<DIV class="ImgChange1" id="focusPic3" style="DISPLAY: none"><A href="TopNews.aspx?TopId=3" target="_blank"><IMG height="369" src="topImg/3.jpg" width="611" border="0"></A>
<TABLE style="CLEAR: both; MARGIN: auto" cellSpacing="1" cellPadding="0" width="98%" align="right"
border="0">
<TBODY>
<TR align="center" bgColor="#9ec9ec">
<TD bgColor="#e2eaf7">&nbsp;</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(1)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">1</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(2)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">2</TD>
<TD style="COLOR: #ffffff" width="26" bgColor="#0049a5">3</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(4)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">4</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(5)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">5</TD>
</TR>
</TBODY>
</TABLE>
</DIV>
<DIV class="ImgChange1" id="focusPic4" style="DISPLAY: none"><A href="TopNews.aspx?TopId=4" target="_blank"><IMG height="369" src="topImg/4.jpg" width="611" border="0"></A>
<TABLE style="CLEAR: both; MARGIN: auto" cellSpacing="1" cellPadding="0" width="98%" align="right"
border="0">
<TBODY>
<TR align="center" bgColor="#9ec9ec">
<TD bgColor="#e2eaf7">&nbsp;</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(1)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">1</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(2)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">2</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(3)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">3</TD>
<TD style="COLOR: #ffffff" width="26" bgColor="#0049a5">4</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(5)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">5</TD>
</TR>
</TBODY>
</TABLE>
</DIV>
<DIV class="ImgChange1" id="focusPic5" style="DISPLAY: none"><A href="TopNews.aspx?TopId=5" target="_blank"><IMG height="369" src="topImg/5.jpg" width="611" border="0"></A>
<TABLE style="CLEAR: both; MARGIN: auto" cellSpacing="1" cellPadding="0" width="98%" align="right"
border="0">
<TBODY>
<TR align="center" bgColor="#9ec9ec">
<TD bgColor="#e2eaf7">&nbsp;</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(1)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">1</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(2)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">2</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(3)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">3</TD>
<TD onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#0049A5'" style="CURSOR: pointer"
onclick="javascript:setFocus1(4)" onmouseout="this.style.color='#004AA7';this.style.backgroundColor='#9EC9EC'"
width="26" bgColor="#9ec9ec">4</TD>
<TD style="COLOR: #ffffff" width="26" bgColor="#0049a5">5</TD>
</TR>
</TBODY>
</TABLE>
</DIV>
</DIV> <!--ImgChangeMain End--></td>
</tr>
</table>
<form id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>

TopNews.aspx前台代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TopNews.aspx.cs" Inherits="fashionArea_TopNews" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>头条新闻</title>
</head>

<body>
<form id="form1" runat="server">
<table width="865" height="211" align="center" cellpadding="0" cellspacing="0" style="border-right: #9ec9eb 1px solid;
border-top: #9ec9eb 1px solid; border-left: #9ec9eb 1px solid; padding-top: 4px;
border-bottom: #9ec9eb 1px solid">
<tr>
<td height="10" width="760">
</td>
</tr>
<tr>
<td id="Title" runat="server" align="center" height="30" style="font-weight: bold; font-size: larger">
</td>
</tr>
<tr>
<td id="newContent" runat="server" style="padding-right: 10px; padding-left: 10px; height: 26px; text-indent: 2em;">
</td>
</tr>
</table>

</form>
</body>
</html>

TopNews.aspx后台代码:

protected void Page_Load(object sender, EventArgs e)
{
string TopId = Request.QueryString["TopId"];

SqlConnection conn = new SqlConnection("Data Source=.;User ID=sa;Password=123;Initial Catalog=kxjm_DB");
conn.Open();
SqlCommand command = new SqlCommand("select * from news where id='" + TopId + "'", conn);
SqlDataReader reader = command.ExecuteReader();

while (reader.Read())
{
Title.InnerText = reader[1].ToString();
newContent.InnerHtml = reader[2].ToString();

}
conn.Close();
command.Dispose();
}

分享到:
评论

相关推荐

    asp+access新闻发布系统-源码

    2) 模板设计--新闻显示页 11 3) 新闻首页的实现--index.asp 11 4) 显示单条新闻--show.asp 13 4. 后台的设计与实现 15 1) 管理主界面的设计 15 2) 框架左边的管理导航--left.asp 16 3) 框架右页的欢迎界面--right....

    ASP.NET 显示在线人数功能

    ASP.NET 显示在线人数功能,历史防问人数.

    ASP.NET项目实训:“新闻发布系统”新闻浏览--新闻显示列表.ppt

    * * * * * * * * * * * * “新闻发布系统”新闻浏览 --新闻显示列表 情景分析 由于新闻在首页按照分类进行了显示,这样使得新闻显示和管理更加规范。对于每一类新闻,我们可能需要浏览更多的新闻,这样就需要有一个...

    ASP滚动新闻代码ASP滚动新闻代码ASP滚动新闻代码

    ASP滚动新闻代码ASP滚动新闻代码ASP滚动新闻代码ASP滚动新闻代码

    asp新闻发布系统

    此处添加的新闻将在前台系统中以分类的形式进行显示。 3.新闻管理模块 此模块的功能是对已有的新闻的各项信息进行修改,对过期的新闻进行删除操作。 4.评论管理模块 此模块的功能是对用户的评论信息进行修改或删除。...

    asp.net 实现网页软键盘功能

    asp.net 实现网页软键盘功能,asp.net源码,实现网页软键盘

    asp 新闻发布系统 模块

    强大的新闻类别管理功能.新闻类别分两层,可以在线对...系统自动识别有图片的新闻,支持新闻图文标志显示功能 有新闻评论功能(管理员可以设定是否开放该功能) 超强的多模版管理功能。可以在线增加,修改和删除模版

    ASP_NET 页生命周期详解

    ASP_NET 页生命周期详解ASP_NET 页生命周期详解ASP_NET 页生命周期详解ASP_NET 页生命周期详解

    asp+access代码-实现注册登录学生信息管理

    p243.asp 显示登录学生记录(1条)信息 3.管理员登录:admin.asp-&gt;loginadmin.asp-&gt;index2.asp n247.asp显示全部学生信息,并带删除、编辑超链接 edit2.asp 编辑后台,del2.asp删除后台 del1.asp按学号删除 ...

    ASP.NET开发详解经典大全

    ASP.NET开发详解经典大全 ASP.NET开发详解经典大全 ASP.NET开发详解经典大全 ASP.NET开发详解经典大全 ASP.NET开发详解经典大全 ASP.NET开发详解经典大全

    荒野Asp.Net组件化新闻系统RC1_2.8.1

    可设头条新闻和图片头条新闻 可设置新闻标题醒目 可以设置相关新闻,在本新闻下显示同一系列新闻的链接 会员可参加新闻点评,可自由发表评论并可选酷表情 管理员分组,超级管理员可自行设定管理员组,并授予...

    [源代码] C# ASP.NET 项目实战 - 新闻发布系统

    后台管理对新闻作了详细的分类,前台以分类形式显示新闻的详细信息,满足了人们浏览新闻时分类查看新闻信息的要求。同时前台还提供查询新闻信息功能,方便浏览者查找相关的新闻信息; ☆ 具体功能:☆ 通过网络,...

    asp函数大全很全面ASP 函数详解(CHM)

    ASP 函数详解(CHM)ASP 函数详解(CHM)

    ASP。net开发常用控件详解

    ASP。net开发常用控件详解。chm电子书格式。

    ASP.NET 新闻发布系统(修改了新闻显示方式)

    这个本人用了 3天多的时间开发的一个新闻发布网站系统,带有单独的后台管理功能,本系统是基于ASP.NET和SQL SERVER 2005 开发的,运用ADO.NET数据库技术,该系统功能较为全面,后天管理功能也很全面,登录带有验证码...

    asp·net生成PDF详解

    asp.net生成PDF详解 asp.net生成PDF PDF详解 用C#制作PDF文件全攻略 丽水市汽车运输集团有限公司信息中心 苟安廷 目 录 前 言 3 第一部分 iText的简单应用 4 第一章 创建一个Document 4 第一步 创建一个Document实例...

    Asp.netXML新闻发布系统

    Asp.net简单XML新闻发布系统

    ASP·NET2·0图解教程

    ASP·NET2·0图解教程ASP·NET2·0图解教程ASP·NET2·0图解教程

    完全手册ASP.NET AJAX实用开发详解 源码

    本书从易到难、由浅入深、循序渐进系统地介绍了ASP.NET AJAX(C#)知识点和基于AJAX的Web应用系统的开发技术。全书通俗易懂,大量的实例供读者更加深刻地巩固所学习的知识,使读者更好地进行开发实践。 本书共分为15...

    基于ASP的Web新闻发布系统的设计(源码+论文)

    1)新闻显示功能模块:主要功能是显示新闻。 2)搜索新闻功能模块:包含按新闻标题搜索和按新闻内容搜索两个模块。 3)新闻评论模块:包含发表评论和浏览评论两个模块。 4)用户管理功能模块:包含用户添加、用户...

Global site tag (gtag.js) - Google Analytics