0

i am doing a project in class that you have to type in a password and have the password given back to you with astrixs which i did but the second part is i have to write an event handler that repeats the password back without the astriks here is my code so far

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

        protected void TxtPassword_TextChanged(object sender, EventArgs e)
    {

    }
}

i forget what i have to put in the txt password field to get it to display i already put a label in can u help me with the next step please?

<form id="form1" runat="server">
    <div>
 
        <asp:TextBox ID="TxtPassword" runat="server" 
            TextMode="Password" ontextchanged="TxtPassword_TextChanged"></asp:TextBox>
        <asp:Label ID="Label1" runat="server" Text="Password"></asp:Label>
    
        <br />
        <asp:Label ID="Label2" runat="server"></asp:Label>
    </div>
    <p>
        &nbsp;</p>
    </form>
</body>
</html>

here is other part in case you need it

5
Contributors
10
Replies
11
Views
7 Years
Discussion Span
Last Post by sknake
0

Set the PassWordChar property of your textbox to '*'.
Put this in your eventhandler:

// Show the text you typed so far
            MessageBox.Show(textBox1.Text);
0

To disable the password character ('*') and display the actual text in the same control:

TxtPassword.UseSystemPasswordChar = false;// or true to turn back on
0

If you set TxtPassword.UseSystemPasswordChar = true;
whenever you type something in your textbox it will be replaced by the bullet character.
If you use TxtPassword.PasswordChar = '$' or '*', all typing in the texbox will be replaced by '$' or '*'.
Put MessageBox.Show(TxtPassword.Text); In your void TxtPassword_TextChanged handler.

0

If you set TxtPassword.UseSystemPasswordChar = true;
whenever you type something in your textbox it will be replaced by the bullet character.
If you use TxtPassword.PasswordChar = '$' or '*', all typing in the texbox will be replaced by '$' or '*'.
Put MessageBox.Show(TxtPassword.Text); In your void TxtPassword_TextChanged handler.

I believe this is correct. So, if I want to achieve the same goal of turning it off in my textbox (show actual text at runtime) when using my own defined PasswordChar, what would be the technique for switching it on and off as you can with the UseSystemPasswordChar property?

0

@DdoubleD
Just set PasswordChar=''; to get back normal behavior in a textBox.

@Ramy
You are absolutely right, but the line is sometimes thin...

0

its not working

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

        
       
        protected void TxtPassword_TextChanged1(object sender, EventArgs e)
        {
            Label2.Text = false;  ?????
        }
}

what belongs here to get the password to show up what do i type for event handler i forget this part

0

The Text property of a Label or a TextBox is of type string, not of type boolean. So assigning false to a Label.Text will not work.
Try this: Label.Text = TxtPassword.Text; and see what happens!
Good luck.

0

You can also set the password property in your .aspx markup:

<asp:TextBox ID="TextBoxPassword" runat="server" TabIndex="2" Width="200px" CssClass="inputBox" TextMode="Password"></asp:TextBox>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.