日期:2014-05-19  浏览次数:20407 次

奇怪的问题:上传控件的click事件不能触发?
我的newtreepost.aspx:
<tr>
  <td   align= "center "> <font   color= "#005ca1 "> <b> 文件上传: </b> </font> </td>
  <td>
    <asp:label   id= "fileinfo "   runat= "server "> </asp:label> <br>
    <input   id= "upfile "   type= "file "   size= "63 "   name= "upfile "   runat= "server ">
    <asp:button   id= "upbutton "   Runat= "server "   Height= "23px "   Text= "   上     传   "         CausesValidation= "False "EnableViewState= "False "> </asp:button>
</td>
</tr>
newtreepost.aspx.cs:
private   void   upbutton_Click(object   sender,   System.EventArgs   e)
{
if   ((this.upfile.PostedFile.ContentLength   ==   0)   ||(this.upfile.PostedFile.ContentLength   >   0x4c4b40))
{
base.Response.Write( " <script> window.alert( '上传文件不能为空或不能大于5MB ') </script> ");
}
else
{
int   num1   =   this.upfile.PostedFile.FileName.LastIndexOf(@ "\ ");
string   text1   =   this.upfile.PostedFile.FileName.Substring(num1   +   1);
string   text2   =   base.Server.MapPath( ". ")   +   @ "\files\ "   +   text1;
this.upfile.PostedFile.SaveAs(text2);
this.fileinfo.Text   =   this.fileinfo.Text   +   this.upfile.PostedFile.FileName   +   " <br> ";
if   ((this.upfile.PostedFile.ContentType   ==   "image/gif ")   ||   (this.upfile.PostedFile.ContentType   ==   "image/pjpeg "))
{
this.Notes.Text=this.Notes.Text   +   " <img   src= 'http://localhost "   +   this.upfile.ResolveUrl( "files/ "   +   text1)   +   " '> ";
}
else
{
this.Notes.Text=this.Notes.Text   +   " <a   href= 'http://localhost "   +   this.upfile.ResolveUrl( "files/ "   +   text1)   +   " '> "   +   text1   +   " </a> ";
}
}
}
------------------------
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_1);
this.Button1.Click   +=   new   System.EventHandler(this.Button1_Click_1);
this.upbutton.Click   +=   new   System.EventHandler(this.upbutton_Click);
this.Load   +=   new   System.EventHandler(this.Page_Load);

}
设置了断点,但是点击   上传   按钮根本就没有什么反应?
大家说说这是怎么回事?

------解决方案--------------------
LZ在Page_Load里面设置个断点
顺便问一句,LZ在Page_Load里有加
if