protected void btnsignup_Click(object sender, EventArgs e) { if (Page.IsValid) { if (Validate()) { if (FileUpload1.HasFile == true) { string fileName = string.Empty; string filePath = string.Empty; fileName = FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf(".")); filePath = Server.MapPath("~/Profile_Pictures/" + Guid.NewGuid() + fileName); FileUpload1.SaveAs(filePath); int fileSize = FileUpload1.PostedFile.ContentLength; if ((fileName.ToLower() == ".jpg" || fileName.ToLower() == ".jpeg" || fileName.ToLower() == ".bmp" || fileName.ToLower() == ".png" || fileName.ToLower() == ".gif") && (fileSize <= 2097152)) //----------------size<=2MB { objPrp.Pemp_f_name = TextBox1.Text; objPrp.Pemp_l_name = TextBox2.Text; objPrp.Pemp_email = TextBox3.Text; objPrp.Pemp_password = TextBox4.Text; objPrp.Pemp_address = TextBox5.Text; objPrp.Pemp_c_number = TextBox6.Text; objPrp.Pemp_e_number = TextBox7.Text; string dob = Page.Request.Form["datepicker"]; objPrp.Pemp_dob = Convert.ToDateTime(Page.Request.Form["datepicker"]); objPrp.Pemp_gender = DropDownList1.SelectedValue; objPrp.Pemp_register_date = DateTime.Now; objPrp.Pemp_picture_path = "../Profile_Pictures/" + filePath.Substring(filePath.LastIndexOf("\\") + 1); int chk_user = obj.request_send(objPrp); if (chk_user == -1) { signupalert.Visible = true; Label2.Text = "Email Id Already Exists"; } else { lblGoogleReCaptcha.Text = "valid recaptcha"; lblGoogleReCaptcha.ForeColor = System.Drawing.Color.Green; clear_rec(); loginForm.Visible = false; successMsg.Visible = true; } } else { signupalert.Visible = true; Label2.Text = "Only images with format .jpg, .bmp, .png, .gif are applicable"; } } else { signupalert.Visible = true; Label2.Text = "Please upload valid image file"; } } else { lblGoogleReCaptcha.Text = "not valid recaptcha"; lblGoogleReCaptcha.ForeColor = System.Drawing.Color.Red; } } else { } }