一个功能完善的专栏管理的程序->这是asp.net的第二个应用(五)
/*
豆腐制作,都是精品
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="images/banner.gif">
<!--广告结束-->
<hr>
<%WriteLanmuClass%>
<hr>
<%
WriteLastArticle
WriteMostClick
%>
</body>
</html>
总结:我们在 学习完 简单的留言版 以后,通过这个 稍微 复杂和实际的应用,对asp.net 的编程应该说已经基本上熟悉了,现在这个程序在 豆腐技术站已经提供下载了。,我们还通过这个程序,对asp.net 的 pagelet 进行了一定的了解和使用,因此通过这写文章,我们已经对asp.net 的编程有了很基础的认识,希望大家 趁热打铁,熟悉一下豆腐的例子,也自己做几个程序看看!
/*
豆腐制作,都是精品
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="images/banner.gif">
<!--广告结束-->
<hr>
<%WriteLanmuClass%>
<hr>
<%
WriteLastArticle
WriteMostClick
%>
</body>
</html>
总结:我们在 学习完 简单的留言版 以后,通过这个 稍微 复杂和实际的应用,对asp.net 的编程应该说已经基本上熟悉了,现在这个程序在 豆腐技术站已经提供下载了。,我们还通过这个程序,对asp.net 的 pagelet 进行了一定的了解和使用,因此通过这写文章,我们已经对asp.net 的编程有了很基础的认识,希望大家 趁热打铁,熟悉一下豆腐的例子,也自己做几个程序看看!