Hi
I am facing an issue with this control. Any help is much appreciated.Below is my requirement
I have to allow maximum of 3 valid files to be uploaded so I set MaxFileInputsCount=3. Now I have some clientside validations and if the files are invalid I am removing them and I cannot see the files in UI but the upload control is not getting back to its original state. Lets say I upload a file and if it is valid I stream it to my DB. Now the count is 1 . I try again with another file and it is not a valid file then I show a message to the user and after the next upload the which is a valid file I am not seeing the upload control. EVen though I have just 2 files uploaded , the control is disappearing. Can anyone help me to resolve this issue. below is my script
function onClientFileUploading(sender, args) {
debugger;
var message = "";
var errorWithFile = false;
var regEx = /[~#%&*{}:<>?\/|\'\"]/;
//Invalid Characters in File Name
if (regEx.test(args.get_fileName())) {
message = "File: " + args.get_fileName() + " contains invalid characters. It has not been uploaded. Please rename the file and upload again.";
errorWithFile = true;
}
//Duplicate File Validation
for (var fileindex in sender._uploadedFiles) {
if (sender._uploadedFiles[fileindex].fileInfo.FileName == args.get_fileName()) {
message = "You have already uploaded a file with the name " + args.get_fileName() + ". Please rename your new file and upload again.";
errorWithFile = true;
break;
}
}
if (errorWithFile) {
--filesSelected;
args.set_cancel(true);
sender._cancelUpload(args.get_row());
sender._updateCancelButton(args.get_row());
var index = $(args.get_row()).index();
sender.deleteFileInputAt(index);
sender.updateClientState();
alert(message);
}
MonitorFileUploadingQueue();
}
function onClientValidationFailed(sender, args) {
var message = "";
var errorWithFile = false;
//File Extension Validation
if (!sender.isExtensionValid(args.get_fileName())) {
message = "File: " + args.get_fileName() + " selected has an invalid extension.";
errorWithFile = true;
}
//MAX File Size
else {
message = "File: " + args.get_fileName() + " has exceeded the " + sender._maxFileSize / 1048576 + " MB file size limit.";
errorWithFile = true;
}
if (errorWithFile) {
debugger;
--filesSelected;
var index = $(args.get_row()).index();
sender.deleteFileInputAt(index);
sender.updateClientState();
alert(message);
}
MonitorFileUploadingQueue();
}
function MonitorFileUploadingQueue() {
if (filesUploaded == filesSelected) {
EnableDisableSubmitButton(true, "");
}
else {
EnableDisableSubmitButton(false, "Uploading Files...");
}
}
Thanks
Rakesh
I am facing an issue with this control. Any help is much appreciated.Below is my requirement
I have to allow maximum of 3 valid files to be uploaded so I set MaxFileInputsCount=3. Now I have some clientside validations and if the files are invalid I am removing them and I cannot see the files in UI but the upload control is not getting back to its original state. Lets say I upload a file and if it is valid I stream it to my DB. Now the count is 1 . I try again with another file and it is not a valid file then I show a message to the user and after the next upload the which is a valid file I am not seeing the upload control. EVen though I have just 2 files uploaded , the control is disappearing. Can anyone help me to resolve this issue. below is my script
function onClientFileUploading(sender, args) {
debugger;
var message = "";
var errorWithFile = false;
var regEx = /[~#%&*{}:<>?\/|\'\"]/;
//Invalid Characters in File Name
if (regEx.test(args.get_fileName())) {
message = "File: " + args.get_fileName() + " contains invalid characters. It has not been uploaded. Please rename the file and upload again.";
errorWithFile = true;
}
//Duplicate File Validation
for (var fileindex in sender._uploadedFiles) {
if (sender._uploadedFiles[fileindex].fileInfo.FileName == args.get_fileName()) {
message = "You have already uploaded a file with the name " + args.get_fileName() + ". Please rename your new file and upload again.";
errorWithFile = true;
break;
}
}
if (errorWithFile) {
--filesSelected;
args.set_cancel(true);
sender._cancelUpload(args.get_row());
sender._updateCancelButton(args.get_row());
var index = $(args.get_row()).index();
sender.deleteFileInputAt(index);
sender.updateClientState();
alert(message);
}
MonitorFileUploadingQueue();
}
function onClientValidationFailed(sender, args) {
var message = "";
var errorWithFile = false;
//File Extension Validation
if (!sender.isExtensionValid(args.get_fileName())) {
message = "File: " + args.get_fileName() + " selected has an invalid extension.";
errorWithFile = true;
}
//MAX File Size
else {
message = "File: " + args.get_fileName() + " has exceeded the " + sender._maxFileSize / 1048576 + " MB file size limit.";
errorWithFile = true;
}
if (errorWithFile) {
debugger;
--filesSelected;
var index = $(args.get_row()).index();
sender.deleteFileInputAt(index);
sender.updateClientState();
alert(message);
}
MonitorFileUploadingQueue();
}
function MonitorFileUploadingQueue() {
if (filesUploaded == filesSelected) {
EnableDisableSubmitButton(true, "");
}
else {
EnableDisableSubmitButton(false, "Uploading Files...");
}
}
Thanks
Rakesh