我是想做一个提交文件图片的类似于邮件的 web窗体 代码如下:
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;
using System.Data.SqlClient;//用的是SQL数据库,
using System.IO ;
using System.Drawing .Imaging ;
namespace ma
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.Label Label7;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected FredCK.FCKeditorV2.FCKeditor FCKeditor1;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Web.UI.WebControls.TextBox TextBox1;
//private BindingManagerBase Navigator;
   // private System.Data .DataSet myDS;
//private System.Data.SqlClient .SqlDataAdapter myAD;
//private System.Data .SqlClient .SqlCommand  myCom;
protected System.Web.UI.WebControls.TextBox TextBox6;
protected System.Web.UI.HtmlControls.HtmlInputFile file2;
protected System.Data .SqlClient .SqlConnection  myCon;
protected System.Web.UI.HtmlControls.HtmlInputFile file3;
protected System.Web.UI.HtmlControls.HtmlInputFile file4;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.HtmlControls.HtmlInputFile file1;

   
private void Page_Load(object sender, System.EventArgs e)
{
string myConStr="Data Source=192.192.192.225;Initial Catalog=jiceng;User Id=sa;Password= ;" ;
   myCon=new SqlConnection(myConStr); 


}
            #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{    

this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button3.Click += new System.EventHandler(this.Button3_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{


HttpFileCollection files=HttpContext.Current.Request .Files ;//得到File表单元素

string fileName;
int fileLength;
string []str=new string [4];

for(int intCount=0;intCount<files.Count ;intCount++)
{
HttpPostedFile postedFile=HttpContext.Current .Request.Files [intCount];
fileLength=postedFile.ContentLength;
fileName=System.IO .Path .GetFileName (postedFile.FileName );//获得文件名字
string FileName=DateTime.Now.ToString ("yyyyMd")+fileName;//获取一个不重复的文件名
try
{
if(fileLength!=0)
{
str[intCount]=FileName;
//fileExtension=System.IO .Path .GetExtension (fileName);//获得文件扩展名
postedFile.SaveAs (System.Web.HttpContext .Current .Request .MapPath ("files/")+FileName);
}
else str[intCount]="";
}
catch
{
Response.Write ("上传文件失败!");
return ;   }
}
    //FileUpload.UploadFile(file2,"C:\\Inetpub\\wwwroot\\ma\\附件-图片");//保存附件
//FileUpload.UploadFile(file3,"C:\\Inetpub\\wwwroot\\ma\\附件-图片");
//FileUpload.UploadFile(file4,"C:\\Inetpub\\wwwroot\\ma\\附件-图片");
try
{
string inser="insert into message(发布单位,标题,内容,图片,附件一,附件二,附件三) values('"+DropDownList1.SelectedValue+"','"+TextBox1.Text +"''"+FCKeditor1.Value+"','"+str[1]+"','"+str[2]+"','"+str[3]+"')";
SqlCommand myCom=new SqlCommand(inser,myCon);
myCon.Open ();
myCom.ExecuteNonQuery ();
myCon.Close ();
SaveFiles();
this.Response .Redirect ("WebForm3.aspx");}
catch{Response.Write("<script language=javascript>alert('保存数据失败!')<script>");
myCon.Close ();}
        

    } private void Button2_Click(object sender, System.EventArgs e)
{
TextBox1.Text ="";
    FCKeditor1.Value="";


} private void Button3_Click(object sender, System.EventArgs e)
{
this.Response .Redirect ("WebForm8.aspx");
}
private void SaveFiles()
{
HttpFileCollection files=HttpContext.Current.Request .Files ;//得到File表单元素

string fileName;
int fileLength;
//string []str=new string [4];
HttpPostedFile Files=HttpContext.Current .Request.Files;

for(int intCount=0;intCount<files.Count ;intCount++)
{
HttpPostedFile postedFile=HttpContext.Current.Request.Files[i];
fileLength=postedFile.ContentLength;
fileName=System.IO .Path .GetFileName (postedFile.FileName );//获得文件名字
string FileName=DateTime.Now.ToString ("yyyyMd")+fileName;//获取一个不重复的文件名
try
{
if(fileLength!=0)
{
//str[i]=FileName;
//fileExtension=System.IO .Path .GetExtension (fileName);//获得文件扩展名
postedFile.SaveAs (System.Web.HttpContext .Current .Request .MapPath ("附件-图片/")+FileName);
}
//else str[i]="";
}
catch
{
Response.Write ("上传文件失败!");
return  ;   }
 
}

}

}

}
逐语句调试时其根本不执行Button1_Click事件 这是哪里的问题啊 急煞我啦