If you use an aspx page with the AsyncFileUpload control in the context of an IFRAME, I experienced the following issue:
Page1
------- IFRAME
-----------------Page2 with AsyncFileUpload (AFU) control
if you upload a file, the AFU control will set the form's target attribute to "_top",
now comes the fatal issue:
use another button control that will do a postback (no matter if update panel or not)
and what happens is that the postback response will load instead of Page1 and therefore jumps out of the IFRAME and "takes over" the place of Page1.
The workaround to this problem was rather simple:
In the client-side event OnClientUploadComplete of the AsyncFileUpload I added the function uploadCompleted which looks like this:
Page1
------- IFRAME
-----------------Page2 with AsyncFileUpload (AFU) control
if you upload a file, the AFU control will set the form's target attribute to "_top",
now comes the fatal issue:
use another button control that will do a postback (no matter if update panel or not)
and what happens is that the postback response will load instead of Page1 and therefore jumps out of the IFRAME and "takes over" the place of Page1.
The workaround to this problem was rather simple:
In the client-side event OnClientUploadComplete of the AsyncFileUpload I added the function uploadCompleted which looks like this:
function uploadComplete(sender)
{
var msg = $get("<%=LabelMsg.ClientID%>");
msg.innerHTML = "<b>File Uploaded Successfully</b>";
$get("<%=ButtonPreview.ClientID%>").style.display = "block";
form1.target = ""; <---------- removes the target _top
$get("<%=HiddenFieldFileName.ClientID%>").value = "";
}
Comments
Post a Comment