Example #1
0
 private bool validateValues()
 {
     if (string.IsNullOrEmpty(txtFirstName.Text))
     {
         txtError.Text = "Enter First Name.";
         return(false);
     }
     else if (string.IsNullOrEmpty(txtLastName.Text))
     {
         txtError.Text = "Enter Last Name.";
         return(false);
     }
     else if (string.IsNullOrEmpty(txtEmail.Text))
     {
         txtError.Text = "Enter Email";
         return(false);
     }
     else if (!ValidationUtil.IsEmail(txtEmail.Text))
     {
         txtError.Text = "Invalid Email.";
         return(false);
     }
     else if (string.IsNullOrEmpty(txtTelephone.Text))
     {
         txtError.Text = "Enter Telephone Number.";
         return(false);
     }
     else if (string.IsNullOrEmpty(txtPassword.Text))
     {
         txtError.Text = "Enter Password.";
         return(false);
     }
     else if (string.IsNullOrEmpty(txtAddress.Text))
     {
         txtError.Text = "Enter Address.";
         return(false);
     }
     else if (string.IsNullOrEmpty(txtCity.Text))
     {
         txtError.Text = "Enter City.";
         return(false);
     }
     else if (string.IsNullOrEmpty(txtState.Text))
     {
         txtError.Text = "Enter State.";
         return(false);
     }
     else if (string.IsNullOrEmpty(txtZipCode.Text))
     {
         txtError.Text = "Enter Zip Code.";
         return(false);
     }
     else if (txtCbCountry.SelectedValue.Equals("0"))
     {
         txtError.Text = "Select Country.";
         return(false);
     }
     return(true);
 }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        bool   bError = false;
        string query  = @"Select CI.Email,UL.Username,UL.Password From CotactInfoes AS CI Inner Join UserLogins AS UL On CI.ContactInfoId = UL.ContactInfoId ";

        if (!string.IsNullOrEmpty(txtEmail.Text))
        {
            if (ValidationUtil.IsEmail(txtEmail.Text))
            {
                query += " Where CI.Email= N'" + Server.HtmlDecode(txtEmail.Text) + "'";
            }
            else
            {
                bError          = true;
                txtMessage.Text = "Enter Valid Email.";
            }
        }
        else
        {
            bError          = true;
            txtMessage.Text = "Enter Username or Email to get Password.";
        }

        if (!bError)
        {
            /*DbDataRecord result = new ObjectQuery<DbDataRecord>(query, entities).FirstOrDefault();
             *
             * if (result != null)
             * {
             *   StringBuilder sb = new StringBuilder();
             *   sb.Append("<html>");
             *   sb.Append("<table border='0' cellpadding='3'cellspacing='0' width='500px' style='font-size:12px; font-family:Arial;'>");
             *   sb.Append("<tr><td colspan='2'>Below is detail of your Email and Password detail.</td></tr>");
             *   sb.Append("<tr><td style='150px'>Email:</td><td style='width:350px;'>" + result.GetValue(result.GetOrdinal("Username")) + "</td></tr>");
             *   sb.Append("<tr><td style='150px'>Password:</td><td style='width:350px;'>" + result.GetValue(result.GetOrdinal("Password")) + "</td></tr>");
             *   sb.Append("</table>");
             *   sb.Append("</html>");
             *   MailMessage mail = new MailMessage(ConfigurationManager.AppSettings["NoReplyEmail"], (string)result.GetValue(result.GetOrdinal("Email")), "Password Recovery Mail", sb.ToString());
             *   mail.IsBodyHtml = true;
             *   SmtpClient client = new SmtpClient(ConfigurationManager.AppSettings["smtphost"], int.Parse(ConfigurationManager.AppSettings["smtpport"]));
             *   client.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["smtpuser"], ConfigurationManager.AppSettings["smtppassword"]);
             *
             *   client.Send(mail);
             *   txtEmail.Text =  string.Empty;
             *   txtMessage.Text = "Password Recovery email has been sent to your registered email address";
             * }
             * else
             * {
             *   txtMessage.Text = "No information found. Please enter valid values.";
             * }*/
        }
    }