function CheckFileControlValidation(source, arguments) { var File_UploadId= source.attributes["controltovalidate"].nodeValue.replace("txt_FilePath","File_Upload") ; var ErrorMsg=""; if( (trim(arguments.Value)=="") && (trim($get(File_UploadId).value)=="")) { arguments.IsValid=false; } else //check user upload file validation if($get(File_UploadId).value!="") { var FileSuffixIndex=$get(File_UploadId).value.lastIndexOf("."); var FileName=$get(File_UploadId).value; var FileSuffix=FileName.substring(FileSuffixIndex+1,FileName.length); var allowSuffixId=File_UploadId.replace("File_Upload","hf_AllowSuffix"); var blockSuffixId=File_UploadId.replace("File_Upload","hf_BlockSuffix"); if($get(blockSuffixId).value!="") { if($get(blockSuffixId).value.toLowerCase().indexOf("*."+FileSuffix.toLowerCase())>-1) { //source.innerHTML="File Suffix Is Blocked"; arguments.IsValid=false; return; } } if($get(allowSuffixId).value!="") { if($get(allowSuffixId).value.toLowerCase().indexOf("*."+FileSuffix.toLowerCase())==-1) { //source.innerHTML="File Suffix Is Not Allowed"; arguments.IsValid=false; return; } } } } function trim(str) { s = str.replace(/^(\s)*/, ''); s = s.replace(/(\s)*$/, ''); return s; } function UpdateFileSrc(File_Upload,txt_File,IconUrl) { var Src=trim($get(File_Upload).value); if(Src!="") { //when we upload new file we need to mark that the image came from the client and no from the server //so in preview we will know how to set the url var hf_NewUpload=File_Upload.replace("File_Upload","hf_NewUpload"); $get(hf_NewUpload).value="true"; $get(txt_File).value=Src; var ImgIcon="ImgIcon"+txt_File; var SuffixIndex = Src.lastIndexOf(".") + 1; var FileSuffix=Src.substring(SuffixIndex); $get(ImgIcon).src=IconUrl+"//"+FileSuffix+".gif"; } } //preview function openFile(senderId,ImageUrl,SiteUrl) { var PageFeatures="scroll:no;dialogHeight: 400px; dialogWidth: 400px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: yes; status: No;"; var txt_FilePath=senderId.replace("ImgPreview",""); var Src=$get(txt_FilePath).value; if(trim(Src)!="") { var hf_NewUpload=txt_FilePath.replace("txt_FilePath","hf_NewUpload"); //if the file is already on the server if($get(hf_NewUpload).value=="false") { Src=ImageUrl+"//"+Src; window.open(Src); } } } //open src function openSrc(Url) { window.open(Url); }