system.aspx.csusing System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.IO;namespace ytepc_train { /// <summary> /// WebForm2 的摘要说明。 /// </summary> public class WebForm2 : System.Web.UI.Page { protected System.Web.UI.HtmlControls.HtmlInputButton UploadFile; protected System.Web.UI.HtmlControls.HtmlInputFile UpFile; protected System.Web.UI.WebControls.DataGrid SystemDG;
我把原代码放上来,需要的拿去
http://www.aspsir.com/download/muliUploadWebApp.rar演示地址:
http://www.aspsir.com/multifilesupload/index.aspx
我把源码贴上来
system.aspx
<%@ Page language="c#" Codebehind="system.aspx.cs" AutoEventWireup="false" Inherits="ytepc_train.WebForm2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>烟台供电公司教育培训系统</TITLE>
<style type="text/css">BODY { FONT-SIZE: 10pt; FONT-FAMILY: Tahoma,Arial,sans-serif }
TD { FONT-SIZE: 10pt; FONT-FAMILY: Tahoma,Arial,sans-serif }
INPUT { FONT-SIZE: 8pt; FONT-FAMILY: Tahoma,Arial,sans-serif }
.heading { FONT-WEIGHT: bold; FONT-SIZE: 14pt; FONT-FAMILY: Tahoma,Arial,sans-serif }
.subhead { FONT-WEIGHT: bold; FONT-SIZE: 12pt; PADDING-BOTTOM: 5px; FONT-FAMILY: Tahoma,Arial,sans-serif }
.cite { FONT-SIZE: 8pt; FONT-FAMILY: Tahoma,Arial,sans-serif }
.rHead { PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-WEIGHT: bold; FONT-SIZE: 14pt; PADDING-BOTTOM: 8px; COLOR: green; PADDING-TOP: 8px; FONT-FAMILY: Lucida Handwriting,Comic Sans MS,Tahoma,Arial }
.rItem { FONT-SIZE: 10pt; FONT-FAMILY: Lucida Handwriting,Comic Sans MS,Tahoma,Arial,sans-serif }
.rFoot { PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 8pt; PADDING-BOTTOM: 8px; COLOR: darkgray; PADDING-TOP: 8px; FONT-FAMILY: Tahoma,Arial }
.Font { FONT-SIZE: 12pt }
</style>
<!-- saved from url=(0055)http://www.fortuneage.com/cn/favision/book_11/index.htm --><LINK href="/Default.vsdisco" type="text/xml" rel="alternate">
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="images/css.css" type="text/css" rel="stylesheet">
<META content="MSHTML 6.00.2600.0" name="GENERATOR">
</HEAD>
<BODY bgColor="#fffff7" leftMargin="0" topMargin="0" MARGINHEIGHT="0" MARGINWIDTH="0">
<TABLE cellSpacing="0" cellPadding="0" width="778" align="center" border="0">
<TBODY>
<TR>
<TD><IMG height="60" alt="" src="images/top_left.gif" width="310"></TD>
<TD><IMG height="60" alt="" src="images/top_banner.jpg" width="468"></TD>
</TR>
<TR>
<TD colSpan="2">
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
<TBODY>
<TR>
<TD width="25%"><IMG height="34" alt="" src="images/top_middle.gif" width="264"></TD>
<TD width="75%" background="images/index_04.gif">
<TABLE cellSpacing="0" cellPadding="0" width="90%" align="center" border="0">
<TBODY>
<TR>
<TD width="33%"><IMG height="18" alt="" src="images/index_06.gif" width="125" border="0"></TD>
<TD width="33%"><IMG height="18" alt="" src="images/index_06.gif" width="125" border="0"></TD>
<TD width="33%"><IMG height="18" alt="" src="images/index_06.gif" width="125" border="0"></TD>
</TR>
<TR>
<TD colSpan="3" height="5"></TD>
</TR>
</TBODY></TABLE>
</TD>
</TR>
</TBODY></TABLE>
</TD>
</TR>
</TBODY></TABLE>
<TABLE cellSpacing="0" cellPadding="0" width="778" align="center" border="0">
<TBODY>
<TR>
<TD height="22"><SPAN id="showImport2"></SPAN><IE:DOWNLOAD id="oDownload2" style="BEHAVIOR: url(#default#download)"></IE:DOWNLOAD>
<DIV align="right"></DIV>
</TD>
</TR>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="0" width="92%" align="center" background="images/index_18.gif" border="0">
<TBODY>
<TR>
<TD width="82%"><IMG height="29" alt="" src="images/index_17.gif" width="168"></TD>
<TD width="18%"><IMG height="29" alt="" src="images/index_20.gif" width="207"></TD>
</TR>
</TBODY></TABLE>
</TD>
</TR>
<TR>
<TD height="12"></TD>
</TR>
<TR>
<TD></TD>
</TR>
</TBODY></TABLE>
<TABLE height="30" cellSpacing="0" cellPadding="0" width="778" align="center" border="0">
<TR>
<TD height="2">
<center><FONT face="宋体"><INPUT id="UpFile" type="file" name="UpFile" runat="server"> <INPUT id="UploadFile" type="button" value="上传" name="UploadFile" runat="server" OnServerClick="UploadFile_ServerClick"></FONT></center>
</TD>
</TR>
</TABLE>
<TABLE cellSpacing="0" cellPadding="0" width="678" align="center" border="0">
<TBODY>
<TR>
<TD vAlign="top" width="2%"><IMG height="35" src="images/content_conner.gif" width="37"></TD>
<TD width="98%" background="images/content_bg.gif"> </TD>
</TR>
<TR>
<TD width="2%" background="images/content_left1.gif"> </TD>
<TD width="98%" bgColor="#ffffff">
<TABLE class="content" height="500" cellSpacing="0" cellPadding="0" width="96%" border="0">
<TBODY>
<TR>
<TD>
<center>
<form runat="server">
<ASP:DATAGRID id="SystemDG" runat="server" OnPageIndexChanged="SystemDG_PageIndexChanged" Width="90%" AllowPaging="True" PageSize="10" PagerStyle-Mode="NumericPages" PagerStyle-HorizontalAlign="Center" BorderColor="black" BorderWidth="0" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" ShowHeader="False">
<SelectedItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></SelectedItemStyle>
<EditItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></EditItemStyle>
<AlternatingItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></AlternatingItemStyle>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle>
<HeaderStyle BackColor="#AAAADD"></HeaderStyle>
<Columns>
<asp:BoundColumn>
<ItemStyle HorizontalAlign="Center" Height="50px" VerticalAlign="Middle"></ItemStyle>
</asp:BoundColumn>
</Columns>
<PagerStyle HorizontalAlign="Center" Mode="NumericPages"></PagerStyle>
</ASP:DATAGRID></form>
</center>
</TD>
</TR>
</TBODY></TABLE>
</TD>
</TR>
<TR>
<TD width="2%" background="images/content_left1.gif"> </TD>
<TD width="98%" bgColor="#ffffff">
<DIV align="center"><IMG height="2" src="images/color.gif" width="450"></DIV>
</TD>
</TR>
</TBODY></TABLE>
<TABLE cellSpacing="0" cellPadding="0" width="778" align="center" border="0">
<TBODY>
<TR>
<TD> </TD>
</TR>
<TR>
<TD bgColor="#bd3839" height="50">
<DIV align="center">
<p><FONT class="genernal-word" color="#ffffff" size="2">建议使用IE4.0以上的浏览器,800*600的分辨率(小字体)观看
</FONT>
</p>
<p><FONT class="genernal-word" color="#ffffff" size="2">2004 YANTAI ELECTRIC POWER
</FONT></p>
</DIV>
</TD>
</TR>
</TBODY></TABLE>
</BODY>
</HTML>
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;namespace ytepc_train
{
/// <summary>
/// WebForm2 的摘要说明。
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlInputButton UploadFile;
protected System.Web.UI.HtmlControls.HtmlInputFile UpFile;
protected System.Web.UI.WebControls.DataGrid SystemDG;
private void Page_Load(object sender, System.EventArgs e)
{
string strConnection="******";
string strSelectall="select jp_systitle from jp_system order by jp_id DESC";
SqlConnection MyConnection= new SqlConnection(strConnection);
MyConnection.Open ();
SqlDataAdapter MyAdapter=new SqlDataAdapter(strSelectall,MyConnection);
DataSet MyDataSet=new DataSet();
MyAdapter.Fill(MyDataSet,"System");
MyConnection.Close();
SystemDG.DataSource=MyDataSet.Tables["System"].DefaultView;
SystemDG.DataBind();
}
public void SystemDG_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
SystemDG.CurrentPageIndex = e.NewPageIndex;
SystemDG.DataBind();
}
void btnPage_Click(Object sender, EventArgs e)
{
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.UploadFile.ServerClick += new System.EventHandler(this.UploadFile_ServerClick);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion public void UploadFile_ServerClick(object sender, System.EventArgs e)
{
HttpPostedFile UpFile1 = UpFile.PostedFile;
string UpFileName;
UpFileName=UpFile1.FileName;
Response.Write(UpFileName);
Response.End();
}
}
}
您把您的EMail告诉我。