· 网络编程· 网页设计· 图形图像· 网站联盟· 数 据 库· 站长时代· 业界资讯· 网站运营· 黑客攻防· 电脑技巧

站长资讯 News
· ASP 专区 · PHP 专区
· JSP 专区 · NET 专区
· XML 专区 · CGI 专区
· 其他相关
热门文章
· FlashMdy快乐行
· 什么是Web3.0
· The World浏览器秘技..
· 游荡在个人网站大潮..
· ASP中Request对象获..
· 今日(2006-11-26)域..
· 实战 FastCGI_2. 安..
· 黑客入侵“在线影院..
· [图文] 认识FrontPag..
· [图文] 谢文写诗袒露..
相关文章
· 这是我上网五年来发..
· 专访施密特:这是Go..
· [图文] 马云揭秘雅巴..
· 周鸿祎回应3721遭封..
· 一个功能完善的专栏..
· 一个功能完善的专栏..
· 一个功能完善的专栏..
· [图文] 这是asp.net的..
您当前的位置:资源库 -> 网络编程 -> NET 专区 -> 文章内容
这是asp.net的第二个应用(五)
作者:佚名  来源:不详  发布时间:2004-6-23 12:10:00  发布人:admin

减小字体 增大字体

/*
豆腐制作,都是精品
http://www.asp888.net 豆腐技术站
如转载,请保留完整版权信息
*/
好了,截止到这里,我们基本上可以说是 公德圆满了!大家可以休息休息了,我们在本章中所讲的内容
就是做一个 专栏管理的 首页,首页应该包括 所有的栏目类别,最近的10篇文章和最热门的10篇文章
我们现在来看看这个本来第一个写的aspx文件:default.aspx
<!--#include file="func.aspx"-->
<script language=vb runat=server>
sub WriteLanmuClass()
dim conn as SQLConnection
conn=getConn()
dim sqlCmd as SqlCommand
dim strSQL as string
dim sRead as SQLDataReader
strSQL="select * from lanmuclass"
sqlCmd=new sqlCommand(strSQL,conn)
sqlCmd.ActiveConnection.open()
sqlCmd.execute(sRead)
dim i as integer
response.write("<table border=1 width=100%><tr><td>")
while(sRead.Read())
response.write("<a href=showarticle.aspx?classid=" & sRead("classid") & ">" & sRead("classname") & "</a>(<font color=red>" & GetClassNum(cStr(sRead("classid"))) & "</font>)")
end while
response.write("</td></tr></table>")
end sub
function GetClassNum(strClassId as string) as string
dim conn as SQLConnection
conn=getConn()
dim sqlCmd as SqlCommand
dim strSQL as string
dim numRead as SQLDataReader
strSQL="select count(*) as ccount from lanmu where classid='" & strClassId & "'"
sqlCmd=new sqlCommand(strSQL,conn)
sqlCmd.ActiveConnection.Open()
sqlCmd.Execute(numRead)
numRead.Read()
GetClassNum=numRead(0)
end function

sub WriteLastArticle()
dim conn as SQLConnection
conn=getConn()
dim sqlCmd as SqlCommand
dim strSQL as string
dim sRead as SQLDataReader
strSQL="select top 10 * from lanmu,lanmuclass where lanmu.classid=lanmuclass.classid and lanmu.isuse='1' order by id desc"
sqlCmd=new sqlCommand(strSQL,conn)
sqlCmd.ActiveConnection.open()
sqlCmd.execute(sRead)
response.Write("<p><font color=gray>最近的文章</font></p>")
response.Write("<table border=0 width=100%>")
while(sRead.Read())
response.Write("<tr>")
response.Write("<td width=100% align=left>")
response.Write("[<a href='showarticle.asp?classid=" & sRead("classid") & "'>" & sRead("classname") & "</a>]")
response.Write("<a href='viewarticle.asp?id=" & sRead("id") & "' target='_blank'>" & sRead("title") & "</a><font color=gray size=1>" & sRead("dtime") & "</gray>")
response.Write("</td>")
response.Write("</tr>")
End While
response.Write("</table>")
end sub

sub WriteMostClick()
dim conn as SQLConnection
conn=getConn()
dim sqlCmd as SqlCommand
dim strSQL as string
dim sRead as SQLDataReader
strSQL="select top 10 * from lanmu,lanmuclass where lanmu.classid=lanmuclass.classid and lanmu.isuse='1' order by viewnum desc"
sqlCmd=new sqlCommand(strSQL,conn)
sqlCmd.ActiveConnection.open()
sqlCmd.execute(sRead)
response.Write("<p><font color=gray>最近的文章</font></p>")
response.Write("<table border=0 width=100%>")
while(sRead.Read())
response.Write("<tr>")
response.Write("<td width=100% align=left>")
response.Write("[<a href='showarticle.asp?classid=" & sRead("classid") & "'>" & sRead("classname") & "</a>]")
response.Write("<a href='viewarticle.asp?id=" & sRead("id") & "' target='_blank'>" & sRead("title") & "</a><font color=gray size=1>" & sRead("dtime") & "</gray>")
response.Write("</td>")
response.Write("</tr>")
End While
response.Write("</table>")
end sub
</script>
<html>
<head>
<title>豆腐技术站-->技术专栏</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Description" Content="探讨ASp,Php 编程,介绍Visual Basic ,Visual C++
等业界最新技术 并提供 免费的各种服务 包括 免费统计系统,免费调查
并提供 招聘站点和 同学录 的服务">
<meta name="Keywords" Content="探讨ASp,Php 编程,介绍Visual Basic ,Visual C++
等业界最新技术 并提供 免费的各种服务 包括 免费统计系统,免费调查
并提供 招聘站点和 同学录 的服务">
<link REL="SHORTCUT ICON" href="http://www.asp888.net/site.ico">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<link rel="stylesheet" type="text/css" href="/doufu.css">
</head>
<body>
<!--广告开始-->
<img src="http://edu.chinaz.com/Get/Program/Net/images/banner.gif">
<!--广告结束-->
<hr>
<%WriteLanmuClass%>
<hr>
<%
WriteLastArticle
WriteMostClick
%>

</body>
</html>

总结:我们在 学习完 简单的留言版 以后,通过这个 稍微 复杂和实际的应用,对asp.net 的编程应该说
已经基本上熟悉了,现在这个程序在 豆腐技术站已经提供下载了
。,我们还通过这个程序,对asp.net 的 pagelet 进行了一定的了解和使用,因此通过这写文章,我们已经
对asp.net 的编程有了很基础的认识,希望大家 趁热打铁,熟悉一下豆腐的例子,也自己做几个程序看看!



 
 
[] [返回上一页] [打 印]
上一篇文章:asp+的页面指示标识