Link to home
Start Free TrialLog in
Avatar of mainrotor
mainrotor

asked on

I need help with a FileUpload control in my ASP.Net 3.5 application

Hi Experts,
I have an ASP.Net 3.5 application with VB.Net codebehind.  I use a FileUpload control in my application to allow the user to browse for a given Excel file.  The control works well most of the time.  I get an error everytime the Excel file I am trying to upload is a Read Only Excel file.  What Is causing this problem?  How can this be fixed?

Thank you in advance,
mrotor
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

What is the error that you get? Is the error before file is uploaded or after?
Avatar of mainrotor
mainrotor

ASKER

I can't tell what the error is.  I just get the generic error page.  I have attached an image of the error and my code aswell.  Please tell me what is wrong.  Do I have to change setting on Visual Studios, or my web.config to trap the error? I have also attached my web.config below:

web.config syntax:
    <customErrors mode="Off" defaultRedirect="GenericErrorPage.htm">
    </customErrors>




 User generated image
Protected Sub sL1_AssignFilePaths()
        Try
            If (fulPriorQtrRSBD12.HasFile = True) Then
                Try
                    strLastQtrPSBD12 = fulPriorQtrRSBD12.PostedFile.FileName
                Catch ex As Exception
                    lblError.Text = "ERROR: " & ex.Message.ToString()
                End Try
            Else
                lblError.Text = "You have not specified a file."
            End If
            If (fulPriorYearRSBD12.HasFile = True) Then
                Try
                    strLastYearPSBD12 = fulPriorYearRSBD12.PostedFile.FileName
                Catch ex As Exception
                    lblError.Text = "ERROR: " & ex.Message.ToString()
                End Try
            Else
                lblError.Text = "You have not specified a file."
            End If
            If (fulPriorQtrPRG.HasFile = True) Then
                Try
                    strPriorQtrPRG = fulPriorQtrPRG.PostedFile.FileName
                Catch ex As Exception
                    lblError.Text = "ERROR: " & ex.Message.ToString()
                End Try
            Else
                lblError.Text = "You have not specified a file."
            End If
            If (fulCurrentQtrPRG.HasFile = True) Then
                Try
                    strCurrentQtrPRG = fulCurrentQtrPRG.PostedFile.FileName
                Catch ex As Exception
                    lblError.Text = "ERROR: " & ex.Message.ToString()
                End Try
            Else
                lblError.Text = "You have not specified a file."
            End If
        Catch ex As Exception
            lblError.Text = ex.Message
        End Try
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial