日期:2011-07-07  浏览次数:20565 次

---StyleSheet.css

.bluebutton
{
 background-color:LightSteelBlue;
 border-style:solid;
 border-width: 1px;
 border-color: LightSkyBlue;
}

---Attachme.aspx

<%@ Page language="c#" Codebehind="Attachme.aspx.cs" AutoEventWireup="false" Inherits="UploadFile.Attachme" %>
<HTML>
 <HEAD>
  <title>多文件上传</title>
  <LINK href="StyleSheet.css" rel="stylesheet">
 </HEAD>
 <body>
  <form id="attachme" method="post" encType="multipart/form-data" runat="server">
   <INPUT class="bluebutton" id="FindFile" type="file" size="26" runat="server" NAME="FindFile">
   <BR>
   <asp:listbox id="FileList" runat="server" CssClass="txtbox" Height="100px" Width="274px" SelectionMode="Multiple"></asp:listbox><BR>
   <asp:button id="AddFile" runat="server" CssClass="bluebutton" Height="23px" Width="72px" Text="添加文件"></asp:button>
   <asp:button id="RemvFile" runat="server" CssClass="bluebutton" Height="23px" Width="72px" Text="删除文件"></asp:button>
   <INPUT class="bluebutton" id="Upload" type="submit" value="上传" runat="server" onserverclick="Upload_ServerClick"
    NAME="Upload">
  </form>
  <asp:label id="TipInfo" runat="server" Height="25px" Width="249px"></asp:label>
 </body>
</HTML>

---Attachme.aspx.cs

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace UploadFile
{
 /// <summary>
 /// 多文件上传
 /// </summary>
 public class Attachme : System.Web.UI.Page
 {
  protected System.Web.UI.WebControls.Button AddFile;
  protected System.Web.UI.WebControls.Button RemvFile;
  protected System.Web.UI.HtmlControls.HtmlInputFile FindFile;
  protected System.Web.UI.HtmlControls.HtmlInputButton Upload;
  protected System.Web.UI.HtmlControls.HtmlGenericControl txtOutput;
  protected System.Web.UI.WebControls.ListBox FileList;
  protected System.Web.UI.WebControls.Label TipInfo;

  static public ArrayList hif = new ArrayList(); // 保存文件列表
  public int filesUploaded = 0; // 上传文件的数量
   
  private void Page_Load(object sender, System.EventArgs e)
  {
  }

  #region Web Form Designer generated code
  override protected void OnInit(EventArgs e)
  {   
   InitializeComponent();
   base.OnInit(e);
  }
       
  /// <summary>
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  /// </summary>
  private void InitializeComponent()
  {   
   this.AddFile.Click += new System.EventHandler(this.AddFile_Click);
   this.RemvFile.Click += new System.EventHandler(this.RemvFile_Click);
   this.Upload.ServerClick += new System.EventHandler(this.