How Do I Enable A File Upload Control When Another File Upload Control Has A Value?

Hi There,

Thanks you for taking the time to read this post.  I am quite new to programming and have searched the net and experimented with my own code but not been able to get it to work yet.

I am creating a simple CMS for a friends site and my friend wants to be able to upload 9 images per page.

I have created an form with 9 file upload controls.  I want 1 control to be enabled by default and the other 8 controls disabled until the previous control has a value.  I have set the default setting in visual studio without any problem.

My first thought was to double click on the file upload control and put some code in there but it doesnt work like buttons where it allows you to enter c# code in the button click event.  It just highlights the asp tag.

Then I tried putting this code in the page load:


        if (FU_Picture1.HasFile == true)
this.FU_Picture2.Enabled = true;


*The fileupload controls are called FU_Picture1 and FU_Picture2.

This only enables the second file upload box when the form is submitted. 

I need the second file upload control to become enabled as soon as the first has a value.  Can anyone suggest a good way of doing this?


Many thanks in advance.


4/19/2008 5:14:44 PM 93655 articles. 6 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 13
Get it on Google Play
Get it on Apple App Store

Rather than putting 9 controls on one page, put 1.

When the user tries to upload the 10th file, your code should say "nah..  you can't do that.'

So... put your FileUpload on the form..   Drop in a Button and tie it to an "OnClick" event handler that looks something like this..


if( fileupload.hasFile ) //or whatever it's called


    if ( ! 9 files are already here)


             //then upload this file

              //hint: look at  System.IO.DirectoryInfo and System.IO.FileInfo



Now... to display your 9 files, you have several options.   You can add Image controls dynamically, or you can use something like a Repeater.


Hope this helps.



4/20/2008 6:56:52 PM

Hi Daniel,

Thank you for your response.  The reason I though to use 9 control was to make it user friendly.

The user enters the name for the page, a description and selects up to 9 pictures.  When they click sumbit the whole form is validated, then the record is created in the database and then the images are uploaded to a data folder and re-named to include the records unique identifyer so as not to cause conflict with other images.

If I did it with one control I assume they would have one form to create the record in the database first and then have another form to add images to records?  Is this what your meant?

Many thanks in advance

4/21/2008 12:26:22 PM

 Hey sorry about the delay..   Did you get this figured out?

" The reason I though to use 9 control was to make it user friendly."

Personally, I believe less buttons = more user friendly.

Drop in your FileUpload, create a button and tie it to an "OnClick" event handler..

In this event handler, you will define the logic you need.  Insert your record, and write the file to a certain folder.

Your Page_Load method should look for these images and/or records and dynamically add Image controls to the form accordingly.

4/29/2008 12:56:43 AM

Similar Artilces:

Deleting A File Uploaded Through File Upload Control
Hello, I have a form which allows a user to upload a file to a virtual drive on our server using the following code: fileInvoice.SaveAs(ConfigurationManager.AppSettings.Get("DocumentPath") + strFileName); //Document Path is defined in the web.config file How can I safely allow a form on a web page to delete the file if they know the exact name of the file. I don't want them to be able to do a wildcard match like test* thanks in advance, mitch  Peace be on you brother, so you want to safely delete the file which the name you know. OK I consider that the name ...

File Upload control-Control file size
I am using a file upload tool. I believe the default permissible size for a file uploaded through this tool is around 4 mb. How do I change this limit? I don't want it to be changed for all upload controls on the page. I just want it to be changed for one particular control which uploads music. I want to raise the uploaded file size limit for music to 10MB. hi, here are some information for you to refer to,

Upload all files in folder with file upload control
H i I'm trying to upload all files to a wesite that is in a specific local folder. My code workes fine when I run it locally but when I upload it it fails. I think it looks for the files to upload on the web server and thus cannot find it.  1 Dim files() As String 2 folderExists = System.IO.Directory.Exists(foldername) 3 If folderExists = False Then 4 Label1.Text = "Folder does not exist. Did you enter a folder name or just a file name ?" 5 Exit sub 6 End If 7 files = System.IO.Directory.GetFiles(foldername) 8 For...

Posting filepath in file upload control in .NET to the next page and uploading the file from second page
In our application (using C# .NET) there is a form with file upload options. After filling up the form details, the summary of the details need to be shown in the next page before committing the information into the database. Right now, Server.Control is used to transfer the contents to the next page and the form details are retrieved using Request.Form["control id"]. But this is not working for File upload control alone.File upload can not be done in the first page itself, as the foreign key in File upload table gets updated only in second page after confirmation. Therefore, is th...

How to identify the original file type and restrict the file uploading while using file upload control
 Hi , I am uploading a file using FileUpload control in using wrote the code to upload only PDF files. the user can change the extension and change to PDF . I have to check is the file original PDF or not then i have to upload the PDF files only . How to do this ??  Hi, Check the file Mime type for "application/pdf" by looking at the:  FileUpload1.PostedFile.ContentType RegardsSmcoxonNo Gem is ever polished without some friction. Hi smcoxon , Thanks For Replying ,But i found that there is no use using PostedFil...

How much size of file can be uploaded with file upload control
How much size of file can be uploaded with file upload control? By default its 4mb but it can be chaged through web config settingsAshok Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point and marks your thread as Resolved. For a detailed explanation on your query have a look into this article Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point...

How to upload an Outlook Message in File Upload control in .Net
Hi All, Is it possible to upload an outlook message from outlook in File Upload control.Please don't suggest to save the message onto the desktop and then upload it!   What I am after is really navigating to the outlook folders through the File Upload control and upload a message.  Thanks guys   If there is a way to do it, but it could be used to maliciously read someone's email folders, forgive me if I hope no one answers you. :)...

Add link buttons to each file uploaded using File upload control
Hi,   In my application I have one file upload control. When the user selectes a file to upload and when he clicks on Attach button I need to show him the file name of the file he selected to upload and also show the Remove link button after the file name. In this case I need to generate link button dynamically. I wrote a code like the following:protected void btnAttach_ServerClick(object sender, EventArgs e) {string strFileName = MyFile.PostedFile.FileName;string c = System.IO.Path.GetFileName(strFileName); listBoxAttachedFiles.Items.Add(c);LinkButton b = new LinkButton(); b.Te...

Is there any limitation of file types that file upload control can be used to upload?
I am working on a content management system which requires me to upload WebEx recording files (.wrf) through file upload control. But I am getting "internet explorer cannot display the webpage" error. It worked with other files types as txt, doc, xls, pdf, jpg, gif etc. Is it related to any security issue or just a bug with the file upload control?  Thank you. The file upload control doesn't have any file type limitations that I'm aware of, but it does have some size constraints.  By default, ASP.NET is configured to not accept any file's larger than 4...

To increase file size upload option of a html file upload control in 1.1
Hi, whenever i try uploading files greater than 15kb or so, my file control fails. But smaller files are easily uploaded. Please helpIf you keep your feet firmly on the ground, you'll have trouble putting on your pants! Hi, the default maximum upload size of the total form data, so not only your fileupload, is limited to 4Mb. You can increase that number by overriding the default settings in the web.config. Alter the <httpRuntime maxRequestLength="" /> attribute. Dealing with the maximum upload size of ASP.NET. Grz, Kris.Read my blog. Handy Firefox plugins for web ...

File name in the file upload control
Hi everyone, Im using file upload control to upload files, on clicking browse button, a dialog box open and selecting the file and "Open". it shows the file C:\Documents and Settings\con_ksprakash\Desktop\mail.doc      only half of the path is visible so, either it has to show text right align focus or i want to display only the file name to user. is it possible ?   thanks in advance.ThanksPrakash.K.S hi, you only want to show the "mail.doc" from fileupload control? as i know, that is not possible, because fileupl...

Is there a way to automate uploading file in a web page using html file input control?
I used a form with a web browser control on it to automate the process of connecting to a website entering the login and password and finish the process of uploading a file.As you navigate to the upload page i can't get the input file control to work automatically because the value property is read only and here is the code HtmlDocument loginPage = wb.Documanet;loginPage.All["file1" ].SetAttributes("value", @"C:\A\A.txt");              //this doesn't work Your help is appreciated. Mark as an answer if it helps. ...

File Upload Control, User Control
I am writing a multiple fileupload control user control. I was trying to do it similar to this. But i am doing it in user control..When i click uplaod. HttpFileCollection uploads = HttpContext.Current.Request.Files; i am using this line to get all the input of type file. but uploads.Count is always giving me 0. Does any one face this problem before? is there a work around? need the solution asap ThanksBetter Post your code before asking some thing, some one. So that person helping u will understand u r problem ClearlyYahoo IM : dotne...

How to upload heavy files with upload control
Hi All I am using ASP Upload control to upload pdfs to my FTP folder which will be accessed by web pages to display the newsletter. But i have tried this  <httpRuntime executionTimeout="360" maxRequestLength="10000"/> This doesn't work in my web.config after setting this i am getting page cannot found error the code i have used in code behind is using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls....

Web resources about - How Do I Enable A File Upload Control When Another File Upload Control Has A Value? -

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Out-of-control car hits Ballajura pedestrians and puts four teens in hospital
Four teenagers were injured in Ballajura on Saturday night when an out-of-control car careered into them.

Obama calls for better gun control, and for tech companies to help fight terrorism
President Barack Obama all but called out encryption in a 15-minute Address to the Nation speech on Sunday night. The President touched on various ...

Chris Christie: NYT gun control op-ed "liberal claptrap"
N.J. governor and GOP presidential candidate tells "Face the Nation" stricter gun laws won't "stop terrorists from attacking us"

Porsche To Mission E Control: We Are Clear For Launch!
... handling of a Porsche. The contrast seemed to start early cries of the Mission E being the next Tesla [&hellip Porsche To Mission E Control: ...

EU could soon have border controls
EU ministers have agreed to press ahead with plans to suspend the Schengen passport-free travel zone, the FT reports.

Windows 10 vs. OS X: Which gives sys admins more control?
Nearly everything can be managed as if it were a mobile device, using APIs at the operating system for assured reach and consistent implementation ...

Erick Erickson Typifies Conservative Insanity On Gun Control
Even though America is averaging one mass shooting a day, and no matter how many Americans get massacred by automatic weapons, conservatives ...

Attorney General Says Obama Could Call For Congressional Action For More Gun Control
Attorney General Says Obama Could Call For Congressional Action For More Gun Control

San Bernardino Shooting: National Rifle Association rubbishes Obama's gun-control appeal
San Bernardino Shooting: National Rifle Association rubbishes Obama's gun-control appeal - Hitting out at Barack Obama for politicising the incident, ...

Resources last updated: 12/7/2015 5:39:37 PM