protected void lnkbtnSave_OnClick(object sender, EventArgs e) { if (chkTermsCondi.Checked) { lnkbtnOTPSend.Visible = false; txtMobileOtp.Text = ""; RegisterDAL obj = new RegisterDAL(); if (obj.IsExists(txtemailid.Text.Trim())) { lblMainSuccessMsg.Visible = true; lblMainSuccessMsg.Text = "User Email id already exists, Please select another Email id"; } else { Random generator = new Random(); Int64 OTP = generator.Next(100000, 999999); ViewState["OTP"] = OTP; lblSuccessMsg.ForeColor = System.Drawing.Color.Green; string Message = "Dear Customer,Your One Time Password is " + OTP + ".Please enter OTP to proceed.Thank you,Team COGXIM"; string Subject = "OTP Varification."; string EmailBody = string.Empty; string OwnerName = txtOwnerName.Text.Trim(); RegisterDAL objtblRegister = new RegisterDAL(); tblEmailTemplate EmailTemplates = objtblRegister.SelectUserMailTemplates("OTP"); EmailBody = EmailTemplates.Body.ToString(); EmailBody = EmailBody.Replace("$$UserName$$", OwnerName); EmailBody = EmailBody.Replace("$$OTP$$", ViewState["OTP"].ToString()); if (SendMailMessage(txtemailid.Text.Trim(), "", "", Subject, EmailBody)) { // Sending mail to user } if (SendMsgForOTP(txtMobileNumber.Text.Trim(), Message)) { multivwRegstr.ActiveViewIndex = 1; lblSuccessMsg.Visible = true; lblSuccessMsg.Text = "Your OTP is send to your mobile number and Email also, Please enter OTP to proceed complete registration"; } else { lblSuccessMsg.Text = "Fetal error!, Please contact to support."; } } } }