用ASP、NET开发下载系统(四)
前台界面部分
下载详细信息页面
下载信息页面其实就是一个Table,左边一列是固定了的,右边一列信息其实就是从数据库中取出当前行的信息,填充到label中。
downDetail.aspx.vb
Public Class downDetail
Inherits System.Web.UI.Page
Protected WithEvents Lbclassname As System.Web.UI.WebControls.Label
Protected WithEvents Lbtitle As System.Web.UI.WebControls.Label
Protected WithEvents lbuploadtime As System.Web.UI.WebControls.Label
Protected WithEvents lbtotaldown As System.Web.UI.WebControls.Label
Protected WithEvents LinkButton1 As System.Web.UI.WebControls.LinkButton
Protected WithEvents lbdescription As System.Web.UI.WebControls.Label
Dim downDs As DataSet
Dim WS As New DownWS.DownWebService()
Dim nID As Int32
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'得到当前的ID
nID = Request.QueryString("id")
'将当前记录的数据传给几个label
downDs = WS.GetDownFromID(nID)
lbdescription.Text = downDs.Tables(0).Rows(0).Item("description").ToString
lbtotaldown.Text = downDs.Tables(0).Rows(0).Item("totaldown")
Lbclassname.Text = downDs.Tables(0).Rows(0).Item("classname")
lbuploadtime.Text = downDs.Tables(0).Rows(0).Item("uploadtime")
Lbtitle.Text = downDs.Tables(0).Rows(0).Item("title")
'下载次数加1
WS.UpdateTotalDown(nID)
'下载地址赋值
HyperLink1.NavigateUrl = ResolveUrl(downDs.Tables(0).Rows(0).Item("filename"))
End Sub
Private Sub InitializeComponent()
End Sub
End Class
关于界面中Table的设置,请看
downDetail.aspx
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="downDetail.aspx.vb" Inherits="WebApplication9.downDetail"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>下载详细信息</title>
<meta content="Microsoft Visual Studio .NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<DIV style="Z-INDEX: 101; LEFT: 6px; WIDTH: 537px; POSITION: absolute; TOP: 2px; HEIGHT: 344px" ms_positioning="FlowLayout">
<table cellSpacing="0" cellPadding="0" width="100%" bgColor="#6876c5" border="0">
<tr>
<td height="25"><font color="white"> 详细信息</font></td>
</tr>
</table>
<table style="WIDTH: 537px; BORDER-COLLAPSE: collapse; HEIGHT: 359px" borderColor="#a0abeb" cellSpacing="0" cellPadding="2" width="537" bgColor="#6876c5" border="1">
<TR bgColor="#eeeeee">
<TD style="WIDTH: 235px; HEIGHT: 28px">软件分类:</TD>
<TD style="HEIGHT: 28px"><asp:label id="Lbclassname" runat="server" Width="430px">Label</asp:label></TD>
</TR>
<TR bgColor="#ffffff">
<TD style="WIDTH: 235px; HEIGHT: 28px">软件名称:</TD>
<TD style="HEIGHT: 28px"><asp:label id="Lbtitle" runat="server" Width="149px">Label</asp:label></TD>
</TR>
<TR bgColor="#eeeeee">
<TD style="WIDTH: 235px; HEIGHT: 28px">上传时间:</TD>
<TD style="HEIGHT: 28px"><asp:label id="lbuploadtime" runat="server" Width="432px">Label</asp:label></TD>
</TR>
<TR bgColor="#ffffff">
<TD style="WIDTH: 235px; HEIGHT: 28px">下载次数:</TD>
<TD style="HEIGHT: 28px"><asp:label id="lbtotaldown" runat="server" Width="432px">Label</asp:label></TD>
</TR>
<TR bgColor="#eeeeee">
<TD style="WIDTH: 235px; HEIGHT: 28px">详细信息:</TD>
<TD style="HEIGHT: 128px"><asp:label id="lbdescription" runat="server" Width="432px">Label</asp:label></TD>
</TR>
<TR bgColor="#ffffff">
<TD style="WIDTH: 235px; HEIGHT: 28px">说明:</TD>
<TD style="HEIGHT: 50px">
<P><FONT color="red">*</FONT> 如出现文件不能正常解压,请下载<A href="/soft/winrar.exe">Winrar3.0</A><BR>
<FONT color="red">*</FONT> 如发现你的超星阅读器不能阅读在本站下载的图书,请重新下载<A href="/soft/ss360.rar"><FONT color="#ff0000">超星阅读器</FONT></A>
安装</A><BR>
<FONT color="red">*</FONT> Author: lihonggen0
</P>
</TD>
</TR>
</table>
<asp:HyperLink id="HyperLink1" runat="server" Width="135px" Height="29px">点击此处下载</asp:HyperLink></DIV>
</FONT>
</form>
</body>
</HTML>
上述代码可存为一个html,在装在Vs.net机器上打开就会出现界面的样子。
总结
通过此实例,我们可以看见一个系统开发的原形,也就是我们在.NET下进行开发的一个典型的例子
本实例只是一个下载系统的原形,在数据库设计和前台界面的设计中,可以有许多改进和功能增强!比如分页可以考虑用SQL SERVER中的存储过程,每次传一页的数据。界面部分的显示可以考虑用DataList,会更加丰富!功能可以再扩展等等!还有就是Web动态引用, 其实就是WS.Url = http://....,再 WS.Discover(),因为篇幅,本文不再描述。
--------------------------------------------------------------------------
Author : lihonggen0
个人专栏:http://www.csdn.net/develop/author/netauthor/lihonggen0/
如需引用,请指明出处!软件的目的在于应用,本文可自由转载!
--------------------------------------------------------------------------