I am tying to upload a image file using asp async file upload.
protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
if (AsyncFileUpload1.HasFile)
{
string filext = Path.GetExtension(AsyncFileUpload1.FileName);
if (filext == ".png")
{
string sessionId = this.Session.SessionID;
string path = Server.MapPath("temp/") + sessionId + filext;
AsyncFileUpload1.SaveAs(path);
Response.Write("-" + path);
string imgSrc = "temp/" + sessionId + filext;
Session["projImage"] = path;
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "showImage", "showImage('" + imgSrc + "');", true);
}
else
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "errorMsgFunction", "errorMsgFunction();", true);
return;
}
}
}
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "showImage", "showImage('" + imgSrc + "');", true);
}
else
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "errorMsgFunction", "errorMsgFunction();", true);
return;
}
out of these the one with image works fine and i can preview correctly but the second javascript funcion doesnot work in chrome
function showImage(imagePath)
{
$('#imgproj', window.parent.document).attr("src", imagePath);
}
function errorMsgFunction(sender, args)
{
$('#diverror', window.parent.document).show();
$('#diverror', window.parent.document).fadeOut(2000);
}