HTML input not working correctly with AJAX update panels used else where on page

Posted by Sean P on Stack Overflow See other posts from Stack Overflow or by Sean P
Published on 2010-05-20T16:42:59Z Indexed on 2010/05/20 18:50 UTC
Read the original article Hit count: 223

Filed under:
|
|
|
|

I have some update panels on my page that do some asyncpostbacks to keep some dropdownlists correctly populated. My problem is that on my page i have an HTML input that is handling some file uploads. With the AJAX on the page with asyncpostbacks, and while i step through my code behind, the files arent being uploaded. Using a postbacktrigger (non-async) is not possible because of my layout.

Here is my code:

      <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>

Here is my code behind:

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

When I put a breakpoint in at the declaration of service and then check the value of "files", the count is 0. I am expecting it to be 2 when i have one file uploaded.

Anyone know how to fix this?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about .NET