ASP·NET头条新闻显示功能详解
2011-10-22 10:01
316 查看
运行效果:
前台代码:
<%@ 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"> </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"> </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"> </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"> </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"> </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();
}
前台代码:
<%@ 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"> </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"> </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"> </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"> </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"> </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();
}
相关文章推荐
- 12.5 Ajax实现RSS频道的显示功能 (征服ASP.NET 2.0 Ajax——Web开发技术详解 )
- 转·ASP.NET验证控件详解
- 12.6 显示频道内容功能 (征服ASP.NET 2.0 Ajax——Web开发技术详解)
- 详解Visual Studio 2010中ASP.NET新增23项功能
- [Asp.Net]<!--[if IE]>....<![endif]-->详解
- asp.net使用for循环实现Datalist的分列显示功能
- ASP.NET中常用功能代码总结(1)——textBox显示规定行数
- Asp.Net 中实现DataGrid指定列的自动累加,汇总,显示合计列功能
- Asp.net 中图片存储数据库以及页面读取显示通用方法详解-附源码下载
- 百度编辑器 ueditor1.1.8.1 For Asp.net 配置 上传功能详解
- [NET]Asp.net日期字符串格式化显示--DateTime.ToString()用法详解
- ASP.NET AJAX (Atlas) 拖放(Drag & Drop)功能6种实现方法总结
- 在ASP.NET 5应用程序中的跨域请求功能详解
- Control Study -> Asp.net几个较复杂的显示数据控件(Repeater/DataList/DataGrid)用法 (示例代码下载)
- 点号“·”的显示 替代 ul li 的功能
- <asp.net> 实现返回功能
- 不错的asp中显示新闻的功能
- ASP.NET AJAX (Atlas) 拖放(Drag & Drop)功能6种实现方法总结
- 百度编辑器 ueditor1.1.8.1 For Asp.net 配置 上传功能详解
- Asp.net 中图片存储数据库以及页面读取显示通用方法详解