We help IT Professionals succeed at work.

How can you program a FileUpload control in ASP.Net 3.5 to browse for Excel files only

mainrotor asked
Medium Priority
Last Modified: 2012-06-27
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.  How can i program the FileUpload control so that it only searches for Excel files (files with the .xls extension only)

Thank you in advance,
Watch Question

Carlos VillegasFull Stack .NET Developer

Hi, Is not exactly what your are asking for but I think that fit into your scenario:
Carlos VillegasFull Stack .NET Developer

By the way, there is not way (in my knowledge) to apply a filter to the web browser file dialogue, but the technique in that link is good to workaround that.
Try using the code given below. This is not exactly what you want but you help you restrict the files to be selected are only excel

if (filename.indexOf(".xls") == -1) {
  alert(filename + " in not an excel file");
} else {
  // process the file...
Unlock this solution and get a sample of our free trial.
(No credit card required)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

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


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.