不显示文本asp.net C#文本框使用文本模式密码 [英] Textbox using textmode password not showing text asp.net c#

查看:886
本文介绍了不显示文本asp.net C#文本框使用文本模式密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web窗体上的几个按钮,当用户点击他们,他们将更新文本框。这个工作,直到我加入了文本模式=密码。现在,文本框不会再显示文本。我调试的应用程序,文本属性所获得的价值,但再次它没有显示。

下面是我曾尝试:

 保护无效btn_punch_7_Click(对象发件人,EventArgs的发送)
    {        常量字符串string_punch_Number_7 =7;
        VAR文本= txt_punch.Text;
        文字+ = string_punch_Number_7;        txt_punch.Text =文本;
    }    保护无效btn_punch_8_Click(对象发件人,EventArgs的发送)
    {
        常量字符串string_punch_Number_8 =8;
        VAR文本= txt_punch.Text;
        文字+ = string_punch_Number_8;        txt_punch.Text =文本;    }

我也厌倦了这一点:

 公共部分类WebForm3:System.Web.UI.Page
{
    公共字符串string_punch;
    保护无效的Page_Load(对象发件人,EventArgs的发送)
    {
        MultiView1.SetActiveView(视图1);        txt_punch.Width = 300;
        txt_punch.Height = 50;
        txt_punch.Max​​Length = 4;
        txt_punch.Attributes.Add(的OnChange,string_punch);    }    保护无效btn_punch_7_Click(对象发件人,EventArgs的发送)
    {        常量字符串string_punch_Number_7 =7;
        string_punch = txt_punch.Text;
        string_punch + = string_punch_Number_7;        txt_punch.Text = string_punch;
    }    保护无效btn_punch_8_Click(对象发件人,EventArgs的发送)
    {
        常量字符串string_punch_Number_8 =8;
        string_punch = txt_punch.Text;
        string_punch + = string_punch_Number_8;        txt_punch.Text = string_punch;    }


解决方案

如何绝望的是你吗?

如果你不够拼命尝试任何事情,任何事情来得到它的工作,不要往下看。这会不会是好的。好? OK。

诀窍是让Web应用程序认为它不是一个密码箱。换句话说,不要使用的TextMode =密码。结果
然后在的Page_Load ,把 txt_punch.Attributes [型] =密码

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

I have a few buttons on a web form, and when the user clicks them they will update the the textbox. This worked till I added the textmode = password. Now the textbox doesn't show the text anymore. I debugged the app, and the text property is getting the value, but once again it is not showing.

Here is what I have tried:

 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;

    }

I have also tired this:

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;

    }

解决方案

How desperate are you?

If you're not desperate enough to try anything, anything to get it to work, don't read on. This will not be nice. OK? OK.

The trick is to make the web app think that it's not a password box. In other words, don't use TextMode="password".
Then in Page_Load, put txt_punch.Attributes["type"] = "password"

That's it. The browser will know it's a password field (and show asterisks or dots), but the server side won't know, so it will send the content to the client as it it were plain text. Of course, this will also put the password in the page source...

这篇关于不显示文本asp.net C#文本框使用文本模式密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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