I have an html input that i use to upload files. Now on my page when I try to authenticate a user first, and hide the div that the controls are in for my file uploads, the collection is empty. When I dont use runat = "server", it works as expected. Not sure how to get around this.
Code: Here is what works...but without hiding... not what I want.
<div id="attachments">
Attachments to add:
<div id="divFileInputs">
<input id="file1" runat="server" name="fileInput" type="file" size="50" style="width: 50em"
onfocus="AddFileInput()" /></div>
<br />
<select id="selectFileList" name="ListBox1" size="5" style="width: 50em; text-align: left" />
<br />
<input id="RemoveAttachmentButton" onclick="RemoveFileInput()" type="button" value="Remove"
class="removebutton " /><br />
<br />
</div>
Here is the code behind that uses it:
Protected Sub CopyAttachments(ByVal issueId As String)
Dim files As HttpFileCollection = Request.Files
Dim myStream As System.IO.Stream
Dim hardwareService As New localhost.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)
hardwareService.ClearQuestAttachToIssue(issueId, fileNameWithoutPath, fileContents)
End If
Next
hardwareService = Nothing
End Sub
Thanks in advance!!!