Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
C#
protected void Chgbtn_Click(object sender, EventArgs e)
        {
            if (newpsstxt.Text != textcontents)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Blank password not allow')", true);
            }
            else
            {
                using (MySqlConnection con = new MySqlConnection(constr))
                {
                    MySqlCommand command = new MySqlCommand("UPDATE emplogin set psswd=@psswd where empno=@empno");
                    {
                        command.Parameters.AddWithValue("@psswd", newpsstxt2.Text);
                        command.Parameters.AddWithValue("@empno", empchglbl.Text);
                        command.Connection = con;
                        con.Open();
                        command.ExecuteNonQuery();
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Password Changed')", true);
                        con.Close();
                    }
                }
                if (IsPostBack)
                {
                    newpsstxt.Text = "";
                    newpsstxt2.Text = "";
                    Panel1.Visible = false;
                }
                MultiView1.ActiveViewIndex = 0;
                {
                }
            }
        }

C#

Posted
Comments
Nigol_Learner 16-Dec-15 16:13pm    
Without enter the text, it's pop up alert message but after enter the text it's direct jump to MultiView1.ActiveViewIndex = 0;...please help me on this.

Debug below code. You will find this condition is false.
C#
if (newpsstxt.Text != textcontents)
 
Share this answer
 
Comments
Nigol_Learner 17-Dec-15 5:59am    
Actually I already declare like this bro,
private string textcontents = ""; ....so I didn't get any error when debug.
C#
protected void Chgbtn_Click(object sender, EventArgs e)
   {
      if (newpsstxt.Text == "")
       {
           ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Blank password not allow')", true);
       }
       else
       {
           using (MySqlConnection con = new MySqlConnection(constr))
           {
               MySqlCommand command = new MySqlCommand("UPDATE emplogin set psswd=@psswd where empno=@empno");
               {
                   command.Parameters.AddWithValue("@psswd", newpsstxt2.Text);
                   command.Parameters.AddWithValue("@empno", empchglbl.Text);
                   command.Connection = con;
                   con.Open();
                   command.ExecuteNonQuery();
                   ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Password Changed')", true);
                   con.Close();
               }
           }
           if (IsPostBack)
           {
               newpsstxt.Text = "";
               newpsstxt2.Text = "";
               Panel1.Visible = false;
           }
           MultiView1.ActiveViewIndex = 0;
           {
           }
       }
   }
 
Share this answer
 
Comments
Nigol_Learner 17-Dec-15 5:56am    
It's work bro thx.
Arasappan 18-Dec-15 23:54pm    
:-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900