protected void btnsubmit_Click(object sender, EventArgs e) { try { if (Session["CheckRefresh"].ToString() == ViewState["CheckRefresh"].ToString()) { DateTime dob = new DateTime(); dob = DateTime.Parse(txtdob.Text, Cul, System.Globalization.DateTimeStyles.NoCurrentDateDefault); DateTime doj = new DateTime(); doj = DateTime.Parse(txtdoj.Text, Cul, System.Globalization.DateTimeStyles.NoCurrentDateDefault); obj.dob = dob.ToShortDateString(); obj.doj =doj.ToShortDateString(); if (FileUpload1.HasFile) { filename = Path.GetFileName(FileUpload1.PostedFile.FileName); //filename = FileUpload1.PostedFile.FileName; Boolean stat = System.IO.File.Exists(Request.PhysicalApplicationPath + "/Upload/" + filename); if (stat == true) { var chars1 = "abcdefghijklmnopqrstuvwxyz0123456789"; var Randomchar = new Random(); var reschar1 = new string(Enumerable.Repeat(chars1, 3).Select(n => n[Randomchar.Next(n.Length)]).ToArray()); filename = reschar1 + ".jpg"; } //string targetPath = Server.MapPath("../Upload/" + filename.ToString()); //Stream strm = FileUpload1.PostedFile.InputStream; //var targetFile = targetPath; FileUpload1.SaveAs(Server.MapPath("../Upload/" + filename)); obj.photo = "../Upload/" + filename.ToString(); } obj.Type = 3; result = obj.Execute(); if (result > 0) { GetCustomercode(); msg.ShowAlertMessage("Inserted Successfully"); clear(); } } else { msg.ShowAlertMessage("select Image"); } Session["CheckRefresh"] = Server.UrlDecode(System.DateTime.Now.ToString()); } catch (Exception ex) { Response.Write(ex.ToString()); } }
Triggers Element Reference
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)