G
GretchenF
Guest
I am building a web page that needs to allow users to select a file to upload.
I have never used the file uploader before, but I don't need to actually move the file anywhere, after they select it I read it and write the info to a database.
I have the "onchange" set to execute a javascript function that calls a subroutine in my vb code that does the work.
The problem I am having is that when I select a file and click the "Open button" the file uploader .HasFile (in my VB code) is false UNLESS I put a breakpoint on the line before my IF statement.
If I do that and then click Continue after selecting the file it works perfectly. If I disable the breakpoint it never selects a file.
I should point out that when the breakpoint is active, it gets hit multiple times, even though I only selcted the file and hit "Open" once and the FileUploadComplete is only referenced in that one spot.
I know this sounds crazy!
Here is what my code looks like:
----------------- ASP.net code
<script type="text/javascript">
function FileUploadComp() {
var AttID = '<%=AttachmentID%>'; //document.getElementByID("FileUpload1");
__doPostBack('FileUpload1', AttID);
}
</script>
<asp:FileUpload ID="FileUpload1" runat="server" AutoPostBack="true" onchange="FileUploadComp();"/>
------------------ VB.net Code
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
....
Else 'If Not IsPostBack
Dim eventTarget As String
Dim eventArgument As String
If (Me.Request("__EVENTTARGET") Is Nothing) Then
eventTarget = String.Empty
Else
eventTarget = Me.Request("__EVENTTARGET")
End If
If (Me.Request("__EVENTARGUMENT") Is Nothing) Then
eventArgument = String.Empty
Else
eventArgument = Me.Request("__EVENTARGUMENT")
End If
Dim valuePassed As String = eventArgument
FileUploadComplete()
End If 'If Not IsPostBack
End Sub
Sub FileUploadComplete()
'This is where I put the breakpoint
debugLine = debugLine + " 100 "
If FileUpload1.HasFile Then
..... this is where the work is done uploading the info from the file
End Sub
Continue reading...
I have never used the file uploader before, but I don't need to actually move the file anywhere, after they select it I read it and write the info to a database.
I have the "onchange" set to execute a javascript function that calls a subroutine in my vb code that does the work.
The problem I am having is that when I select a file and click the "Open button" the file uploader .HasFile (in my VB code) is false UNLESS I put a breakpoint on the line before my IF statement.
If I do that and then click Continue after selecting the file it works perfectly. If I disable the breakpoint it never selects a file.
I should point out that when the breakpoint is active, it gets hit multiple times, even though I only selcted the file and hit "Open" once and the FileUploadComplete is only referenced in that one spot.
I know this sounds crazy!
Here is what my code looks like:
----------------- ASP.net code
<script type="text/javascript">
function FileUploadComp() {
var AttID = '<%=AttachmentID%>'; //document.getElementByID("FileUpload1");
__doPostBack('FileUpload1', AttID);
}
</script>
<asp:FileUpload ID="FileUpload1" runat="server" AutoPostBack="true" onchange="FileUploadComp();"/>
------------------ VB.net Code
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
....
Else 'If Not IsPostBack
Dim eventTarget As String
Dim eventArgument As String
If (Me.Request("__EVENTTARGET") Is Nothing) Then
eventTarget = String.Empty
Else
eventTarget = Me.Request("__EVENTTARGET")
End If
If (Me.Request("__EVENTARGUMENT") Is Nothing) Then
eventArgument = String.Empty
Else
eventArgument = Me.Request("__EVENTARGUMENT")
End If
Dim valuePassed As String = eventArgument
FileUploadComplete()
End If 'If Not IsPostBack
End Sub
Sub FileUploadComplete()
'This is where I put the breakpoint
debugLine = debugLine + " 100 "
If FileUpload1.HasFile Then
..... this is where the work is done uploading the info from the file
End Sub
Continue reading...