예제 #1
0
    protected void btnChange_Click(object sender, EventArgs e)
    {
        bool result = true;

        if (txtNewPassword.Text.Equals(""))
        {
            lblNpasswordEmptyError.Visible       = true;
            lblCNpasswordEmptyError.Visible      = false;
            lblComparepasswordWrongError.Visible = false;
            lblNpasswordEmptyError.Text          = "Enter a new password !";
            result = false;
        }
        if (txtConfirmNewPassword.Text.Equals(""))
        {
            lblCNpasswordEmptyError.Visible      = true;
            lblNpasswordEmptyError.Visible       = false;
            lblComparepasswordWrongError.Visible = false;
            lblCNpasswordEmptyError.Text         = "Confirm your new password !";
            result = false;
        }
        if (txtNewPassword.Text != txtConfirmNewPassword.Text)
        {
            lblCNpasswordEmptyError.Visible      = false;
            lblNpasswordEmptyError.Visible       = false;
            lblComparepasswordWrongError.Visible = true;
            lblCNpasswordEmptyError.Text         = "Confirm your new password correctly !";
            result = false;
        }

        if (result)
        {
            string user   = Session["user"].ToString();
            bool   status = dba.changepassword(user.ToLower(), txtNewPassword.Text);
            if (status)
            {
                Response.Redirect("~/PasswordChangeSuccess.aspx");
            }

            else
            {
                lblCNpasswordEmptyError.Visible      = false;
                lblNpasswordEmptyError.Visible       = false;
                lblComparepasswordWrongError.Visible = false;
                lblResult.Visible = true;
                lblResult.Text    = "Passworrd Not Changed Success !";
            }
        }
    }
예제 #2
0
 protected void btnChange_Click(object sender, EventArgs e)
 {
     if (txtpassword.Text.Equals(""))
     {
         lblEmptyPasswordError.Visible = true;
         lblEmptyAnswerError.Text      = "Enter a new password !";
     }
     else
     {
         lblEmptyPasswordError.Visible = false;
         bool status = dba.changepassword(txtUserName.Text.ToLower(), txtpassword.Text);
         if (status)
         {
             Response.Redirect("~/Recovered Success.aspx");
         }
         else
         {
             lblPasswordChangeStatus.Visible = true;
             lblPasswordChangeStatus.Text    = "Recovered fail !";
         }
     }
 }