2012-02-17 54 views
0

問題誤差的UpdatePanel

當我把

<asp:FileUpload ID="FileUpload1" runat="server" class="multi" /> <br /> <asp:Button ID="btnUpload" runat="server" Text="Upload All" />更新面板一切工作正常之外,但只要我把它放回更新面板...它停止工作。

ASPX CODE

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="try.aspx.vb" Inherits="AdminPanel_try" %> 

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
    <script src="../js/multi-upload/jquery-1.3.2.js" type="text/javascript"></script> 
    <script src="../js/multi-upload/jquery.MultiFile.js" type="text/javascript"></script> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
     <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> 
     </asp:ToolkitScriptManager> 
     <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
     <ContentTemplate> 
     <asp:FileUpload ID="FileUpload1" runat="server" class="multi" /> 
     <br /> 
     <asp:Button ID="btnUpload" runat="server" Text="Upload All" /> 
     </ContentTemplate> 
      <Triggers> 
       <asp:AsyncPostBackTrigger ControlID="btnUpload" EventName="Click" /> 
      </Triggers> 
     </asp:UpdatePanel> 

    </div> 
    </form> 
</body> 
</html> 

後面的代碼

Partial Class AdminPanel_try 
    Inherits System.Web.UI.Page 
    Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click 
     Try 
      ' Get the HttpFileCollection 
      Dim hfc As HttpFileCollection = Request.Files 
      For i As Integer = 0 To hfc.Count - 1 
       Dim hpf As HttpPostedFile = hfc(i) 
       If hpf.ContentLength > 0 Then 
        hpf.SaveAs(Server.MapPath("MyFiles") & "\" & System.IO.Path.GetFileName(hpf.FileName)) 
        Response.Write("<b>File: </b>" & hpf.FileName & " <b>Size:</b> " & hpf.ContentLength & " <b>Type:</b> " & hpf.ContentType & " Uploaded Successfully <br/>") 
       End If 
      Next i 
     Catch ex As Exception 

     End Try 
    End Sub 
End Class 

注: 我使用本教程kindly check this link

+0

沒有看見你的筆記在底部的時候,我提交了答案,希望我的回答是一些使用的仍 – sellmeadog 2012-02-17 21:24:35

回答