protected void btnUpload_Click(object sender, EventArgs e) { try { if (FileUpload1.HasFile) { var FileExtension = "." + Path.GetExtension(FileUpload1.PostedFile.FileName).Substring(1); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Vetting\\VetAtt\\"); Guid GUID = Guid.NewGuid(); string AttachPath = "VET_" + GUID.ToString() + FileExtension; FileUpload1.SaveAs(sPath + AttachPath); if (Convert.ToInt32(Session["DDLAttachment_Value"].ToString()) != 4) { string confirmValue = Request.Form["confirm_value"]; if (confirmValue == "Yes") { objBLLIndx.VET_Upd_VettingAttachments(Convert.ToInt32(Vetting_ID), Convert.ToInt32(Session["DDLAttachment_Value"].ToString()), Path.GetFileName(FileUpload1.PostedFile.FileName), AttachPath, Convert.ToInt32(Session["userid"].ToString())); LoadAttachment(); DDLAttachment.SelectedValue = "0"; } else if (confirmValue == null) { objBLLIndx.VET_Ins_VettingAttachments(Convert.ToInt32(Vetting_ID), Convert.ToInt32(Session["DDLAttachment_Value"].ToString()), Path.GetFileName(FileUpload1.PostedFile.FileName), AttachPath, Convert.ToInt32(Session["userid"].ToString())); LoadAttachment(); DDLAttachment.SelectedValue = "0"; } else if (confirmValue == "No") { string jsSqlError2 = "alert('Attachment for selected type already exists.');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "jsSqlError2", jsSqlError2, true); DDLAttachment.SelectedValue = "0"; } } else { objBLLIndx.VET_Ins_VettingAttachments(Convert.ToInt32(Vetting_ID), Convert.ToInt32(Session["DDLAttachment_Value"].ToString()), Path.GetFileName(FileUpload1.PostedFile.FileName), AttachPath, Convert.ToInt32(Session["userid"].ToString())); LoadAttachment(); DDLAttachment.SelectedValue = "0"; } } } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); string js = "alert('" + UDFLib.GetException("SystemError/ GeneralMessage") + "');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "error", js, true); } }