ASP.Net page with input file ( every button uploads file, how do I prevent )

Posted on 2005-05-10
Last Modified: 2010-04-07
I have an page built with controls and linkbuttons all over the place. Every link or button on the page posts my one form to the server. This page also has a file input html control, and now all the buttons on page tries to upload the file, when I would only want this to happen if the submit button is pressed.

Is there any .net way to disable the file upload when certain control events are thrown?

Question by:brooklynDev
    LVL 33

    Accepted Solution

    you can implement some of the logic mentioned here to disable the file control right before you postback:

    looks something like this in the submit handler of the other controls that can postback:
    document.getElementById('myFile').disabled = true; return true;

    Also, why can't the file control just remain blank, it can't upload what hasn't been selected by the end user!


    Expert Comment

    That solution looks promising, I'll try it now

    raterus, to answer your question, the control can remain blank, I just want the cancel button to clear the elements of the form without uploading the file if one has been selected.

    Expert Comment

    I read through your terms and conditions, yes, please delete my old account

    sorry about the confusion, was an accident

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now