在Asp.Net中重新加载页面后,文本框的值仍然显示

问题描述

   protected void Page_Load(object sender,EventArgs e)
    {
     if (!IsPostBack)
        {
            if (Request.Cookies["UserName"] != null && Request.Cookies["Password"] != null)
            {
                txtUserName.Text = Request.Cookies["UserName"].Value;
                
                txtPass.Attributes.Add("value",Convert.ToString(Request.Cookies["Password"].Value));
               
                CheckBox1.Checked = true;
            }
        }

    }

    protected void btnLogIn_Click(object sender,EventArgs e)
    {           
            if (dt.Rows.Count != 0)
            {  }
            else
            {
                lblMsg.Visible = true;
                lblMsg.Text = "Login In Failed";
            }

            ClearField();
        }
    }

    protected void ClearField()
    {
        txtUserName.Text = string.Empty;
        txtPass.Text = string.Empty;
    }

执行我的 else 条件时。它不会清空我的 txtPass 文本框,如果我输入的密码错误,它将在文本框中显示正确的密码。

我认为Cookie出了点问题,但idk如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)