protected void lnkbtn_otp_Click(object sender, EventArgs e) { if (Session["CheckRefresh"].ToString() == ViewState["CheckRefresh"].ToString()) { Session["CheckRefresh"] = Server.UrlDecode(System.DateTime.Now.ToString()); if (Page.IsValid) { txt_otp.Text = ""; bl.UserID = txt_username.Text; dt = dl.Select_user_detail(bl); if (dt.table.Rows.Count > 0) { Session["user"] = bl.UserID; bl1.RegistrationID = dt.table.Rows[0]["RegistrationID"].ToString(); dt = dl1.Select_User_detail(bl1); if (dt.table.Rows.Count > 0) { bl1.OTP = dl1.GenOTPString(8); bl1.EmailID = dt.table.Rows[0]["EmailID"].ToString(); bl1.UserID = dt.table.Rows[0]["UserID"].ToString(); bl1.MobileNo = dt.table.Rows[0]["MobileNo"].ToString(); bl1.Type = "Password Forget"; bl1.UserIP = ul.GetClientIpAddress(this.Page); bl1.Sms_detail = "your OTP for Userid " + bl.UserID + " is " + bl1.OTP + ". Do Not disclose Your OTP With AnyOne. it is Valid For 10 minutes."; bl1.RegistrationID = dt.table.Rows[0]["RegistrationID"].ToString(); bl1.EmailID = dt.table.Rows[0]["EmailID"].ToString(); Session.Add("OTP", bl1.OTP); rb = dl1.InsertOtp(bl1); if (rb.status == true) { div1.Visible = true; div2.Visible = false; } } else { Utilities.MessageBoxShow_Redirect("You Are Not Registered User ", "../Login.aspx"); } } else { Utilities.MessageBoxShow_Redirect("user id Not Recognised Please Create new ID ", "../Login.aspx"); } } } }
protected void btn_send_Click(object sender, EventArgs e) { if (Session["CheckRefresh"].ToString() == ViewState["CheckRefresh"].ToString()) { Session["CheckRefresh"] = Server.UrlDecode(System.DateTime.Now.ToString()); txt_otp.Text = ""; bl.RegistrationID = Session["REGID"].ToString(); dt = dl.Select_User_detail(bl); if (dt.table.Rows.Count > 0) { bl.OTP = dl.GenOTPString(8); bl.EmailID = dt.table.Rows[0]["EmailID"].ToString(); bl.UserID = dt.table.Rows[0]["UserID"].ToString(); bl.MobileNo = txt_mobile.Text; bl.Type = Session["VERIFICATION_TYPE"].ToString(); bl.UserIP = ul.GetClientIpAddress(this.Page); bl.Sms_detail = "your OTP for Userid " + bl.UserID + " is " + bl.OTP + ". Do Not disclose Your OTP With AnyOne. it is Valid For 10 minutes."; bl.RegistrationID = dt.table.Rows[0]["RegistrationID"].ToString(); bl.EmailID = dt.table.Rows[0]["EmailID"].ToString(); Session.Add("OTP", bl.OTP); rb = dl.InsertOtp(bl); if (rb.status == true) { btn_send.Text = "Resend"; div_otp.Visible = true; Utilities.MessageBox_UpdatePanel(udp, "One Time Password Has Been Sended To Your Mobile Please Varify"); } else { btn_send.Text = "send"; } } else { Response.Redirect("../LogOut.aspx"); } } }
protected void btn_send_Click(object sender, EventArgs e) { if (Session["CheckRefresh"].ToString() == ViewState["CheckRefresh"].ToString()) { Session["CheckRefresh"] = Server.UrlDecode(System.DateTime.Now.ToString()); txt_otp.Text = ""; bl.RegistrationID = Session["REGID"].ToString(); dt = dl.Select_User_detail(bl); if (dt.table.Rows.Count > 0) { bl.OTP = dl.GenOTPString(8); bl.EmailID = dt.table.Rows[0]["EmailID"].ToString(); bl.UserID = dt.table.Rows[0]["UserID"].ToString(); bl.MobileNo = txt_mobile.Text; bl.Type = Session["VERIFICATION_TYPE"].ToString(); bl.UserIP = ul.GetClientIpAddress(this.Page); bl.Sms_detail = "your OTP for Userid " + bl.UserID + " is " + bl.OTP + ". Do Not disclose Your OTP With AnyOne. it is Valid For 10 minutes."; bl.RegistrationID = dt.table.Rows[0]["RegistrationID"].ToString(); bl.EmailID = dt.table.Rows[0]["EmailID"].ToString(); Session.Add("OTP", bl.OTP); rb = dl.InsertOtp(bl); if (rb.status == true) { div_otp.Visible = true; // Email sending Code Added By Naveen on 09-oct-2017 Start // The below code for sending email is working need to give the from account mail id and password /* * string fromMail = "From gmail ID here"; * string fromPass = "******"; * using (MailMessage mm = new MailMessage(fromMail, bl.EmailID)) * { * mm.Subject = "Registration OTP"; * mm.Body = bl.Sms_detail; * mm.IsBodyHtml = false; * SmtpClient smtp = new SmtpClient(); * smtp.Host = "smtp.gmail.com"; * smtp.EnableSsl = true; * NetworkCredential NetworkCred = new NetworkCredential(fromMail, fromPass); * smtp.UseDefaultCredentials = true; * smtp.Credentials = NetworkCred; * smtp.Port = 587; * smtp.Send(mm); * } */ // Email sending Code Added By Naveen on 09-oct-2017 end string str_msg = ""; if (Session["language"].ToString() == "en-GB") { btn_send.Text = "Resend"; str_msg = "One Time Password Has Been Sended To Your Mobile Please Verify"; } else { btn_send.Text = "फिर से भेजें"; str_msg = "आपका वन टाइम पासवर्ड आपके मोबाईल न. पर भेज दिया गया है|कृपया जाँच कर लें| "; } Utilities.MessageBox_UpdatePanel(udp, str_msg); } else { if (Session["language"].ToString() == "en-GB") { btn_send.Text = "send"; } else { btn_send.Text = "भेजें"; } // btn_send.Text = "send"; } } else { Response.Redirect("../LogOut.aspx"); } } }