加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

文本框使用textmode密码不显示文本asp.net c#

发布时间:2020-12-15 23:03:49 所属栏目:asp.Net 来源:网络整理
导读:我在Web表单上有几个按钮,当用户点击它们时,它们将更新文本框.这一直工作,直到我添加了textmode = password.现在文本框不再显示文本.我调试了该应用程序,并且text属性正在获取该值,但是再一次显示. 这是我试过的: protected void btn_punch_7_Click(object
我在Web表单上有几个按钮,当用户点击它们时,它们将更新文本框.这一直工作,直到我添加了textmode = password.现在文本框不再显示文本.我调试了该应用程序,并且text属性正在获取该值,但是再一次显示.

这是我试过的:

protected void btn_punch_7_Click(object sender,EventArgs e)
    {

        const string string_punch_Number_7 = "7";
        var text = txt_punch.Text;
        text += string_punch_Number_7;

        txt_punch.Text = text;


    }

    protected void btn_punch_8_Click(object sender,EventArgs e)
    {
        const string string_punch_Number_8 = "8";
        var text = txt_punch.Text;
        text += string_punch_Number_8;

        txt_punch.Text = text;

    }

我也累了这个:

public partial class WebForm3 : System.Web.UI.Page
{
    public string string_punch;
    protected void Page_Load(object sender,EventArgs e)
    {
        MultiView1.SetActiveView(View1);

        txt_punch.Width = 300;
        txt_punch.Height = 50;
        txt_punch.MaxLength = 4;
        txt_punch.Attributes.Add("OnChange",string_punch);

    }

    protected void btn_punch_7_Click(object sender,EventArgs e)
    {

        const string string_punch_Number_7 = "7";
        string_punch = txt_punch.Text;
        string_punch += string_punch_Number_7;

        txt_punch.Text = string_punch;


    }

    protected void btn_punch_8_Click(object sender,EventArgs e)
    {
        const string string_punch_Number_8 = "8";
        string_punch = txt_punch.Text;
        string_punch += string_punch_Number_8;

        txt_punch.Text = string_punch;

    }

解决方法

你多么绝望

如果你不是绝望地尝试任何东西,任何事情都可以让它工作,不要继续阅读.这不会很好好?好.

诀窍是使网络应用程序认为它不是密码框.换句话说,不要使用TextMode =“password”.
然后在Page_Load中,将txt_punch.Attributes [“type”] =“password”

而已.浏览器会知道它是一个密码字段(并显示星号或点),但是服务器端将不会知道,所以它会将内容发送到客户端,因为它是纯文本.当然这也会把密码放在页面源码里

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读