MaxNumberToUpload is set only once. Count for the same is not updated if user deletes the file


MaxNumberToUpload specifies the no. of files that can be allowed for the user to upload. If I set it to 1 and then try and upload a file, it allows me to do so. Now, if I remove the added file and then try to upload some other file, the control gives me a pop-up saying: "You have exceeded the total allowable number of files to upload.". This is because, when we click on the cross button "x" in the FileUploadRowControl, the count of files currently present in the control to upload is not updated accordingly, which gives rise to this issue. This can be modified to track the actual no. of files being uploaded during a single operation.


belarussianby wrote Oct 25, 2011 at 1:46 PM

Found a source of probleme:

FileUploadControl has variable called counter which is declared as global variable for the current FileUploadControl class - private int count = 0;
This variable is never reset when click on "Clear" button or "Remove file" image in the grid. To fix this just add counter=0 to "Clear" button event.

For removing single file we need to decriment variable. A problem is that event is in the FileUpload class. So to fix this issue we need to :

1) Create public property or variable in FileUpload class.
2) On "Remove" button click event decriment created variable

belarussianby wrote Oct 25, 2011 at 2:00 PM



easiest way to modify single file delete is just to put counter++ in the end of "Add files" button click event after file was added to the array:


// File was added -> counter update

Before check if number of files added more allowed to upload add this line:

// Check if added file exceeds total number of allowed files.
count = files.Count + 1;

Do not need to create public property or variable in FileUpload class!!!!

wrote Feb 14, 2013 at 8:10 PM