一个功能完善的专栏管理的程序->这是asp.net的第二个应用(五)

一个功能完善的专栏管理的程序->这是asp.net的第二个应用(五)
/*
豆腐制作,都是精品
http://www.asp888.net 豆腐技术站
如转载,请保留完整版权信息
*/
好了,截止到这里,我们基本上可以说是 公德圆满了!大家可以休息休息了,我们在本章中所讲的内容就是做一个 专栏管理的 首页,首页应该包括 所有的栏目类别,最近的10篇文章和最热门的10篇文章我们现在来看看这个本来第一个写的aspx文件:default.aspx

 1<script language="vb" runat="server">   
 2sub WriteLanmuClass()   
 3dim conn as SQLConnection   
 4conn=getConn()   
 5dim sqlCmd as SqlCommand   
 6dim strSQL as string   
 7dim sRead as SQLDataReader   
 8strSQL="select * from lanmuclass"   
 9sqlCmd=new sqlCommand(strSQL,conn)   
10sqlCmd.ActiveConnection.open()   
11sqlCmd.execute(sRead)   
12dim i as integer   
13response.write("<table border=1 width=100%><tr><td>")   
14while(sRead.Read())   
15response.write("<a href=showarticle.aspx?classid=" & sRead("classid") & ">" & sRead("classname") & "</a>(<font color=red>" & GetClassNum(cStr(sRead("classid"))) & "</font>)")   
16end while   
17response.write("</td></tr></table>")   
18end sub   
19function GetClassNum(strClassId as string) as string   
20dim conn as SQLConnection   
21conn=getConn()   
22dim sqlCmd as SqlCommand   
23dim strSQL as string   
24dim numRead as SQLDataReader   
25strSQL="select count(*) as ccount from lanmu where classid='" & strClassId & "'"   
26sqlCmd=new sqlCommand(strSQL,conn)   
27sqlCmd.ActiveConnection.Open()   
28sqlCmd.Execute(numRead)   
29numRead.Read()   
30GetClassNum=numRead(0)   
31end function   
32  
33sub WriteLastArticle()   
34dim conn as SQLConnection   
35conn=getConn()   
36dim sqlCmd as SqlCommand   
37dim strSQL as string   
38dim sRead as SQLDataReader   
39strSQL="select top 10 * from lanmu,lanmuclass where lanmu.classid=lanmuclass.classid and lanmu.isuse='1' order by id desc"   
40sqlCmd=new sqlCommand(strSQL,conn)   
41sqlCmd.ActiveConnection.open()   
42sqlCmd.execute(sRead)   
43response.Write("<p><font color=gray>最近的文章</font></p>")   
44response.Write("<table border=0 width=100%>")   
45while(sRead.Read())   
46response.Write("<tr>")   
47response.Write("<td width=100% align=left>")   
48response.Write("[<a href='showarticle.asp?classid=" & sRead("classid") & "'>" & sRead("classname") & "</a>]")   
49response.Write("<a href='viewarticle.asp?id=" & sRead("id") & "' target='_blank'>" & sRead("title") & "</a><font color=gray size=1>" & sRead("dtime") & "</gray>")   
50response.Write("</td>")   
51response.Write("</tr>")   
52End While   
53response.Write("</table>")   
54end sub   
55  
56sub WriteMostClick()   
57dim conn as SQLConnection   
58conn=getConn()   
59dim sqlCmd as SqlCommand   
60dim strSQL as string   
61dim sRead as SQLDataReader   
62strSQL="select top 10 * from lanmu,lanmuclass where lanmu.classid=lanmuclass.classid and lanmu.isuse='1' order by viewnum desc"   
63sqlCmd=new sqlCommand(strSQL,conn)   
64sqlCmd.ActiveConnection.open()   
65sqlCmd.execute(sRead)   
66response.Write("<p><font color=gray>最近的文章</font></p>")   
67response.Write("<table border=0 width=100%>")   
68while(sRead.Read())   
69response.Write("<tr>")   
70response.Write("<td width=100% align=left>")   
71response.Write("[<a href='showarticle.asp?classid=" & sRead("classid") & "'>" & sRead("classname") & "</a>]")   
72response.Write("<a href='viewarticle.asp?id=" & sRead("id") & "' target='_blank'>" & sRead("title") & "</a><font color=gray size=1>" & sRead("dtime") & "</gray>")   
73response.Write("</td>")   
74response.Write("</tr>")   
75End While   
76response.Write("</table>")   
77end sub   
78</script>
 1<html>
 2<head>
 3<title>豆腐技术站--&gt;技术专栏</title>
 4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 5<meta content="探讨ASp,Php 编程,介绍Visual Basic ,Visual C++   
 6等业界最新技术 并提供 免费的各种服务 包括 免费统计系统,免费调查   
 7并提供 招聘站点和 同学录 的服务" name="Description"/>
 8<meta content="探讨ASp,Php 编程,介绍Visual Basic ,Visual C++   
 9等业界最新技术 并提供 免费的各种服务 包括 免费统计系统,免费调查   
10并提供 招聘站点和 同学录 的服务" name="Keywords"/>
11<link href="http://www.asp888.net/site.ico" rel="SHORTCUT ICON"/>
12<meta content="no-cache" http-equiv="Pragma"/>
13<link href="/doufu.css" rel="stylesheet" type="text/css"/>
14</head>
15<body>
16<!--广告开始-->
17<img src="images/banner.gif"/>
18<!--广告结束-->
19<hr/>   

WriteLanmuClass

1<hr/>   

WriteLastArticle
WriteMostClick

1  
2</body>
3</html>

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

Published At
Categories with Web编程
Tagged with
comments powered by Disqus