protected void btnSaveImage_Click(object sender, EventArgs e) { if (Page.IsValid) { BEStudent objBEStudent = new BEStudent(); BStudent objBStudent = new BStudent(); objBEStudent.IntUserID = Convert.ToInt32(Session[BaseClass.EnumPageSessions.USERID]); if (IdentificationFileUpload.HasFile) { string strpath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["UploadedDocumentsLocation"]); string strOriginalFileName = IdentificationFileUpload.FileName; string strUploadFileName = CommonFunctions.generateUploadFileName(IdentificationFileUpload.FileName); string strTotalPath = strpath + '\\' + strUploadFileName; string pathex = Path.GetExtension(strTotalPath); if (pathex.ToLower() == ".jpg" || pathex.ToLower() == ".jpeg" || pathex.ToLower() == ".gif" || pathex.ToLower() == ".png" || pathex.ToLower() == ".bmp") { //IdentificationFileUpload.SaveAs(strTotalPath); System.Drawing.Image img = System.Drawing.Image.FromStream(IdentificationFileUpload.PostedFile.InputStream); int height = img.Height; int width = img.Width; decimal size = Math.Round(((decimal)IdentificationFileUpload.PostedFile.ContentLength / (decimal)1024), 2); if (size > 999) { Stream strm = IdentificationFileUpload.PostedFile.InputStream; var targetFile = strTotalPath; ReduceImageSize(0.3, strm, targetFile); } else { IdentificationFileUpload.SaveAs(strTotalPath); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowFailure", "alert('" + Resources.ResMessages.Reg_Validuploadfiles + "')", true); return; } objBEStudent.strUploadPath = strUploadFileName; objBEStudent.strOriginalFileName = strOriginalFileName; } else { objBEStudent.strUploadPath = string.Empty; objBEStudent.strOriginalFileName = string.Empty; } objBStudent.BUploadPhotoIdentity(objBEStudent); if (objBEStudent.IntResult > 0) { lblUpload.Text = "<img src='../Images/yes.png'align='middle'/> <font color='#00C000'>" + Resources.ResMessages.MyProfile_FileUploadSuccess + "</font>"; this.getPhotoIdentity(); ValidatePhotoIdentity(); ScriptManager.RegisterStartupScript(this, this.GetType(), "NotSaved", "document.getElementById('" + lblUpload.ClientID.ToString() + "').focus();", true); Session["UPLOAD"] = "YES"; Response.Redirect("MyProfile.aspx"); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "NotSaved", "document.getElementById('" + RequiredFieldValidator13.ClientID.ToString() + "').focus();", true); Session["UPLOAD"] = "NO"; Response.Redirect("MyProfile.aspx"); } } }