Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My Method requires refresh in order to show uploaded photo for user.How to avoid refreshing of page for user.
protected void fileUploadComplete(object sender, AsyncFileUploadEventArgs e)
{
Thread.Sleep(1000);
try
{
string profileimg = "", name = "", formid = "", ext = "";
if (Session["DisplayName"] != null && Convert.ToString(Session["DisplayName"]) != "" && Session["FormId"] != null && Convert.ToString(Session["FormId"]) != "")
{
name = Convert.ToString(Session["DisplayName"]);
formid = Convert.ToString(Session["FormId"]);
profileimg = Convert.ToString(ConfigurationManager.AppSettings["ProfileImg"]) + name.Split(' ')[0] + "_" + formid;

if (fileUpload1.HasFile)
{
ext = System.IO.Path.GetExtension(fileUpload1.FileName);
Bitmap bmpImg = null;
newfilenameWithExt = profileimg + ext;
if (hdnOldFileName.Value != "")
{
string oldFilePath = Server.MapPath("~/") + "/storedata/" + "studentphotos/" + hdnOldFileName.Value;
FileInfo oldFile = new FileInfo(oldFilePath);
if (System.IO.File.Exists(oldFilePath))
System.IO.File.Delete(oldFilePath);
}

StudentApplication objStdFileUpload = new StudentApplication();
objStdFileUpload.StudentFormID = 0;
objStdFileUpload.StudentFormID = Convert.ToInt32(Session["FormId"].ToString());
objStdFileUpload.StudentProfileImage = newfilenameWithExt;

if (objStdFileUpload.StudentFormID != 0)
{
objStdFileUpload.UpdateFileNameUploadByFormID();

// Resize Image Before Uploading to Storedata
bmpImg = Resize_Image(fileUpload1.PostedFile.InputStream, 350, 262);
bmpImg.Save(Server.MapPath("~/") + "/storedata/" + "studentphotos/" + newfilenameWithExt, ImageFormat.Jpeg);
hdnFileNmWithoutExt.Value = Convert.ToString(ConfigurationManager.AppSettings["Home"]) + "storedata/studentphotos/" + newfilenameWithExt;
imgStudentImage.ImageUrl = Server.MapPath("~/storedata/studentphotos/") + newfilenameWithExt;
}
}
}
}
catch (Exception ex)
{
MessageControl1.ErrorMessage("Error:- " + ex.ToString());
}
}
Posted
Updated 23-Jul-14 20:43pm
v3

1 solution

Have you tried an updatepanel ?
 
Share this answer
 
Comments
sp_suresh 24-Jul-14 8:41am    
Yes Updatepanel is used but even then its not success

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900