protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (StopProcessing) { // Do nothing } else { ScriptHelper.RegisterJQuery(Page); ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Content/Controls/Attachments/DirectFileUploader/DirectFileUploader.js"); if (!RequestHelper.IsPostBack() || ForceLoad) { ReloadData(); } if (ControlGroup != null) { // First instance of the control is loaded RequestStockHelper.AddToStorage(DIRECT_FILE_UPLOADER_STORAGE_KEY, ControlKey, true, true); string script = String.Format(@" function DFULoadIframes_{0}() {{ if (window.File && window.FileReader && window.FileList && window.Blob) {{ return; }} var iframe = document.getElementById('{1}'); if (iframe!=null) {{ iframe.setAttribute('allowTransparency','true'); if (window.DFUframes != null) {{ var iframes = $cmsj('iframe.{2}'); for(var i = 0; i < iframes.length; i++) {{ var f = iframes[i]; var p = f.parentNode.parentNode; var imgs = p.getElementsByTagName('img'); if ((imgs != null) && (imgs[0] != null)) {{ p.removeChild(imgs[0]); }} var o = null; var cw = iframe.contentWindow; if (cw != null) {{ var cwd = cw.document; if (cwd != null) {{ var cn = cwd.childNodes; if ((cn != null) && (cn.length > 0) && (cn[1].innerHTML != null)) {{ var containerId = DFUframes[f.id].match(/containerid=([^&]+)/i)[1]; o = cn[1].innerHTML; o = o.replace(/action=[^\\s]+/, 'action=""' + DFUframes[f.id] + '""').replace('{3}',''); o = o.replace(/(\.\.\/)+App_Themes\//ig, '{4}App_Themes/'); o = o.replace(/OnUploadBegin\('[^']+'\)/ig, 'OnUploadBegin(\'' + containerId + '\')'); var cd = f.contentWindow.document; cd.write(o); cd.close(); f.style.display = ''; f.setAttribute('allowTransparency','true'); }} }} }} }} }} }} }}", ControlKey, uploaderFrame.ClientID, IFrameCSSClass, ERROR_FUNCTION, ResolveUrl("~")); RegisterScript("DFUIframesLoader_" + ControlKey, script); } } }