Replies
Hi Miro Hristov,
Thanks!!
I was able to achieve it based on your code. Here is the complete set of code I used:
//Page Load
function pageLoad() {
//Hook function to the file selected event
$('#<%=WebUpload1.ClientID %>').igUpload({
fileSelected: function(event, eventArgs) {
if (!isValidFileName(eventArgs.filePath)) {
alert('File Name Validation failed!')
$(this).igUpload('cancelUpload', eventArgs.fileId);
}
}
});
}
Also, I had some code written in the igFileUploaded event (which is still fired). So I checked that as well:
function igFileUploaded(sender, eventArgs) {
if (eventArgs.filePath != undefined && eventArgs.filePath != '') {
//Code to be fired only if file name validation is success
}
}
I have not done exhaustive testing on this, but it looks pretty much robust.
Thanks,
Sharon
Hi Miroslav,
Thanks for your reply.
Regarding cancelling upload, the link you provided, although is related to my query, has no verified answer.
My requirement is pretty simple. I have set AutoStartUpload="true" in my web upload control. When user selects a file, I want to run a validation on the file name and stop upload if name does not match a criteria (Please note that this is NOT a file extension validation). I want to do this in client side.
I have tried the following if my validation fails:
1. return false in igFileSelected and check eventArgs.fileStatus in igFileUploading
2. Added code $("#<%=WebUpload1.ClientID %>").igUpload("cancelUpload", 1); in igFileSelected and check eventArgs.fileStatus in igFileUploading
In both cases, the fileStatus is 2 which accordiing to this link means File Upload is finished.
Can you please suggest a solution?
Thanks,
Sharon
Hi Miro Hristov,
Thanks! The code you have provided hides the Summary Bar. I actually wanted to hide the Progress Bar when mode is "Single". I used Firebug like you suggested and was able to achieve the desired result :
$('#<%=WebUpload1.ClientID %>_fc').hide()
Regards,
Sharon
Hi Miro Hristov,
You have correctly pointed out the problem – the file upload ID is not correct because the length is shown 0 in debugger. Unfortunately, I have tried different ways but still cant get the ID right.
My page has a master page and the upload control is seen to to rendered as following when I viewed source from browser:
<div id="ctl00_ContentPlaceHolder1_WebUpload1">
</div>
I have tried out the following ways but still no luck, all show length zero:
1. $('#ctl00_ContentPlaceHolder1_WebUpload1_summpbar')
2. $('#' + '<%=WebUpload1.ClientID %>' + '_summpbar')
3. $('#WebUpload1_summpbar')
Awaiting reply.
Hi Miro Hristov,
Thank you for your response.
I tried implementing the solution you suggested, but it does not seem to work. The progress bar is not geting hidden. Please help!
Code:
function igFileUploaded(sender, eventArgs) {
$('#ctl00_ContentPlaceHolder1_WebUpload1_spbcntr').hide();
//$('#' + '<%=WebUpload1.ClientID %>' + '_spbcntr').hide();
//$('#WebUpload1_spbcntr').hide();
}
<ig:WebUpload ID="WebUpload1" runat="server" AutoStartUpload="true" ShowFileExtensionIcon="true" OnUploadFinished="WebUpload1_UploadFinished" ClientEvents-FileUploaded="igFileUploaded" ClientEvents-FileUploading="igFileUploading" LabelAddButton="Replace File"></ig:WebUpload>
Thanks,
Sharon