Code is working great. The preview after picking image using asyncfileupload appears. But once I place the page into an iframe
, it doesn't work anymore.
I think the problem is that once it is place into the iframe
,
this script : top.$get(\"" + ImagePreview.ClientID + "\") can't really find my ImagePreview
.
I tried using document.getElementById("<%= ImagePreview.ClientID %>") but no success.
protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
if (AsyncFileUpload1.HasFile)
{
Session["AsyncFileUpload1"] = AsyncFileUpload1;
this.Session["AsyncFileUploadBytes"] = AsyncFileUpload1.FileBytes;
Random random = new Random();
int num = random.Next(10);
string savePath = MapPath("~/Images/Temp/Preview" + num + ".jpg");
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "size", "top.$get(\"" + AsyncFileUpload1.ClientID + "\").innerHTML = 'Uploaded size: " + AsyncFileUpload1.FileBytes.Length.ToString() + "';", true);
AsyncFileUpload1.SaveAs(savePath);
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "image", "top.$get(\"" + ImagePreview.ClientID + "\").src = '../../../Images/Temp/Preview" + num + ".jpg'", true);
}
}