分享
 
 
 

用ASP、NET开发下载系统(三)

王朝c#·作者佚名  2006-12-17
窄屏简体版  字體: |||超大  

用ASP、NET开发下载系统(三)

前台界面部分主界面主界面是左上部分是一个TreeView控件,用来添加分类信息。

主界面是左下部分是一个List控件,用来显示下载信息排行榜。

主界面是右边部分是一个DataGrid控件,用来显示下载信息。

这是一个基本的界面,如果需要更多功能,请自行扩充!

步骤:新建一项目(选择asp.net应用程序),添加Web 引用, 重命名为DownWS

在窗体上添加DataGrid,用属性生成器设置其属性:列、分页、格式等,然后在代码中为DataGrid设置数据源,再绑定后,呈现上述样式。

再添加TreeView,List等控件。在程序中将数据添加到TreeView,详细代码请见下面:

注:

Internet Explorer WebControls不在VS.NET的标准Server Control中,到微软的站点下载:http://msdn.microsoft.com/downloads/samples/internet/default.asp?url=/Downloads/samples/Internet/ASP_DOT_NET_ServerControls/WebControls/default.asp 下载安装后第一次使用时,要右击工具箱Customize Toolbox…→.NET Framework Components中找到Micosoft.Web.UI.WebControls.Treeview后选中,这样Treeview控件就出现在工具箱中了。

downinfo.aspx.vb:Imports System.Configuration

Imports System.Data

Imports System.Data.SqlClient

Imports Microsoft.Web.UI.WebControls

Public Class downInfo

Inherits System.Web.UI.Page

Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid

Protected WithEvents TreeView1 As Microsoft.Web.UI.WebControls.TreeView

Protected WithEvents Label2 As System.Web.UI.WebControls.Label

Protected WithEvents Label3 As System.Web.UI.WebControls.Label

Protected WithEvents ListBox1 As System.Web.UI.WebControls.ListBox

Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm

#Region " Web 窗体设计器生成的代码 "

'该调用是 Web 窗体设计器所必需的。

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

' CODEGEN: 此方法调用是 Web 窗体设计器所必需的

'不要使用代码编辑器修改它。

InitializeComponent()

End Sub

#End Region

Dim downDv As New DataView()

Dim strName As String

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'

strName = Request.QueryString("strName")

'实例化一个DownWebService

Dim WS As New DownWS.DownWebService()

Dim dsTree As DataSet

'得到所有的分类

dsTree = WS.GetDownClass

'填充到树状结构中

TreeView1.Nodes.Clear()

Dim Row As DataRow

For Each Row In dsTree.Tables(0).Rows

Dim item As New TreeNode()

item.Text = Row.Item("classname").ToString

'点击时的网址跳转

item.NavigateUrl = "downinfo.aspx?strname=" & Row.Item("classname").ToString

'每个分支的图片

item.ImageUrl = ResolveUrl(Me.TemplateSourceDirectory & "\tree.jpg")

TreeView1.Nodes.Add(item)

Next

'得到所有下载信息,进行分类的过滤后,填充到DataGrid

downDv = WS.GetDownInfo().Tables(0).DefaultView

If strName <> "" Then

downDv.RowFilter = "classname='" & strName & "'"

End If

DataGrid1.DataSource = downDv

DataGrid1.DataBind()

End Sub

Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged

'得到当前的ID

Dim nID As Int32 = DataGrid1.SelectedItem.Cells(0).Text

'得到URL

Dim strUrl As String = "downdetail.aspx?ID=" + nID.ToString()

'打开一个窗口,没有工具栏,状态条

Response.Write("<script language='javascript'>open('" + strUrl + "','pop','directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,height=450,width=595');</script>")

End Sub

Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged

'处理分页

DataGrid1.CurrentPageIndex = e.NewPageIndex

DataGrid1.DataSource = downDv

DataGrid1.DataBind()

End Sub

End Class

downinfo.aspx:<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="downInfo.aspx.vb" Inherits="WebApplication9.downInfo"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<title>XX下载系统</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: 150px; WIDTH: 741px; POSITION: absolute; TOP: 82px; HEIGHT: 412px" ms_positioning="FlowLayout"><FONT face="宋体"><asp:datagrid id="DataGrid1" runat="server" ForeColor="Black" BackColor="White" AllowPaging="True" AutoGenerateColumns="False" Height="212px" Width="739px" BorderColor="#6876C5" GridLines="Vertical" PageSize="20">

<SelectedItemStyle ForeColor="White" BackColor="DeepSkyBlue"></SelectedItemStyle>

<AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle>

<HeaderStyle ForeColor="White" BackColor="#6876C5"></HeaderStyle>

<FooterStyle ForeColor="White" BackColor="#6876C5"></FooterStyle>

<Columns>

<asp:BoundColumn DataField="id" HeaderText="编号">

<HeaderStyle Width="80px"></HeaderStyle>

</asp:BoundColumn>

<asp:BoundColumn DataField="classname" HeaderText="分类名称">

<HeaderStyle Width="120px"></HeaderStyle>

</asp:BoundColumn>

<asp:HyperLinkColumn DataNavigateUrlFormatString="webform2.aspx?ID={0}" DataTextField="title" HeaderText="标题" NavigateUrl="filename">

<HeaderStyle Width="320px"></HeaderStyle>

</asp:HyperLinkColumn>

<asp:BoundColumn DataField="uploadtime" HeaderText="上传时间">

<HeaderStyle Width="180px"></HeaderStyle>

</asp:BoundColumn>

<asp:BoundColumn DataField="totaldown" HeaderText="下载次数">

<HeaderStyle Width="100px"></HeaderStyle>

</asp:BoundColumn>

<asp:ButtonColumn Text="下载" HeaderText="下载" CommandName="Select">

<HeaderStyle Width="60px"></HeaderStyle>

</asp:ButtonColumn>

</Columns>

<PagerStyle HorizontalAlign="Center" ForeColor="White" BackColor="#6876C5" Mode="NumericPages"></PagerStyle>

</asp:datagrid></FONT></DIV>

<DIV style="Z-INDEX: 103; LEFT: 19px; WIDTH: 131px; POSITION: absolute; TOP: 81px; HEIGHT: 497px" ms_positioning="FlowLayout"><asp:label id="Label2" runat="server" ForeColor="White" BackColor="#6876C5" Width="129px">软件分类 </asp:label><iewc:treeview id="TreeView1" runat="server"></iewc:treeview><asp:label id="Label3" runat="server" ForeColor="White" BackColor="#6876C5" Width="129px">下载排行</asp:label><asp:listbox id="ListBox1" runat="server" Height="191px" Width="130px"></asp:listbox></DIV>

</form>

</FONT>

</body>

</HTML>

--------------------------------------------------------------------------

Author : lihonggen0

个人专栏:http://www.csdn.net/develop/author/netauthor/lihonggen0/

如需引用,请指明出处!软件的目的在于应用,本文可自由转载!

--------------------------------------------------------------------------

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有