文本框模式更改模式时为null文本

时间:2017-10-09 09:00:00

标签: c# asp.net

我尝试使用按钮更改TextMode字段。在此操作期间,文本被清除

 protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
  string  constring2 = passwordtxt.Text;
    if (passwordtxt.TextMode == TextBoxMode.Password)
    {
        passwordtxt.TextMode = TextBoxMode.SingleLine;
        ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert(+constring)</script>");

    }
   else 
    {
        passwordtxt.TextMode = TextBoxMode.Password;
        ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Inserted succussfully')</script>");

    }
    passwordtxt.Text = constring2;
}

0 个答案:

没有答案