We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

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

Medium Priority
315 Views
Last Modified: 2012-05-11
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
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
What is the error that you get? Is the error before file is uploaded or after?

Author

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




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

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.