2012-08-04 140 views
1

哪裏錯誤?如果我不使用ajax,那麼表單是有效的,並且文件正在上傳,但是現在頁面重新加載並且...文件未加載到路徑中,爲什麼?上傳文件在asp,AJAX

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <ContentTemplate> 
    <p> 

     <asp:FileUpload ID="FileUpload1" runat="server" /> 
     &nbsp;<asp:Button ID="Button1" runat="server" onclick="Upload" Text="downdoad..." 
     BackColor="#0099CC" Font-Size="Small" /> 
    </p> 
    </ContentTemplate> 
    </asp:UpdatePanel> 
    <asp:UpdateProgress ID="UpdateProgress1" runat="server"> 
     <ProgressTemplate> 
      downdoad... 
     </ProgressTemplate> 
    </asp:UpdateProgress> 

回答

-1
protected void Button1_Click(object sender, EventArgs e) 
    { 
     if (FileUpload1.HasFile) 
     { 
      FileUpload1.SaveAs(Server.MapPath("~/Uploads" + FileUpload1.FileName)); 
      Label1.Text = "Saved Successfully"; 
     } 
     else 
     { 
      Label1.Text = "File Not found"; 
     } 
    } 

在上面的代碼文件不添加在上傳文件夾