为什么即使在文本框中输入文本也无法继续? [英] Why Can't proceed even enter the text in textbox?

查看:81
本文介绍了为什么即使在文本框中输入文本也无法继续?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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;
                {
                }
            }
        }





推荐答案

调试下面的代码。你会发现这个条件是假的。

Debug below code. You will find this condition is false.
if (newpsstxt.Text != textcontents)


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;
           {
           }
       }
   }


这篇关于为什么即使在文本框中输入文本也无法继续?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆