2010-05-20 21 views
0

我在我的頁面上有一些更新面板做一些asyncpostbacks,以保持一些dropdownlist正確填充。我的問題是,在我的網頁上我有一個處理一些文件上傳的HTML輸入。在帶有asyncpostbacks的頁面上使用AJAX,並且當我遍歷我的代碼時,這些文件不會被上傳。由於我的佈局,使用postbacktrigger(非異步)是不可能的。HTML輸入無法正常使用AJAX更新面板使用其他地方

這裏是我的代碼:

 <div id="divFileInputs" runat="server"> 
        <input id="file1" name="fileInput" type="file" runat="server" size="50" style="width: 50em" 
         onfocus="AddFileInput()" class="textbox" /></div> 
       <select id="selectFileList" name="ListBox1" size="5" style="width: 50em; text-align: left;" 
        class="textbox" /> 
       <input id="RemoveAttachmentButton" type="button" value="Remove" onclick="RemoveFileInput()" 
        class="removebutton " /> 
      </div> 

這裏是我的代碼背後:

Protected Sub CopyAttachments(ByVal issueId As String) 

    Dim files As HttpFileCollection = Request.Files 
    Dim myStream As System.IO.Stream 

    Dim service As New SubmitService.Service 
    For i As Integer = 0 To files.Count - 1 

     Dim postedFile As HttpPostedFile = files(i) 
     Dim fileNameWithoutPath As String = System.IO.Path.GetFileName(postedFile.FileName) 

     If fileNameWithoutPath.Length > 0 And issueId.Length > 0 Then 
      Dim fileLength As Integer = postedFile.ContentLength 
      Dim fileContents(fileLength) As Byte 

      ' Read the file into the byte array. Send it to the web service. 
      myStream = postedFile.InputStream 
      myStream.Read(fileContents, 0, fileLength) 
      service.ClearQuestAttachToIssue(issueId, fileNameWithoutPath, fileContents) 
     End If 
    Next 

    service = Nothing 
End Sub 

當我把一個斷點在服務的聲明,然後檢查的「文件」的價值,計數是0.我期待它是2當我有一個文件上傳。

任何人都知道如何解決這個問題?

回答

0

好的,這裏是解決方案。我使用的提交按鈕附加到AJAX asncypostback。因此不回發整個頁面。我改變它只是一個回發更新面板和賓果..工作!

相關問題