How to convert asp.net TextBox TextMode SingleLine to Password

How to convert, change TextBox TextMode SingleLine to Password
asp.net web server control has a property called TextMode. TextMode property have three possible values SingleLine, MultiLine and Password. we can change the textbox TextMode property value by writing it within textbox tags or coding it in c# script section. to assign TextMode property value programmatically we need to use TextBoxMode enumeration.

this example demonstrate you how can we change textbox text mode single line to password. SingleLine mode generate a single line standard textbox and Password mode generate a textbox which specially created to input password value. Password mode textbox text are not readable for user but you can get the password text from textbox Text property value.
TextBoxTextMode.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        TextBox1.TextMode = TextBoxMode.Password;
        Label1.Text = "Password";
    }
    protected void Button2_Click(object sender, System.EventArgs e)
    {
        TextBox1.TextMode = TextBoxMode.SingleLine;
        Label1.Text = "UserName";
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to convert, change TextBox TextMode SingleLine to Password</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Green">TextBox Example: SingleLine Password</h2>
        <asp:Label 
             ID="Label1" 
             runat="server"
             Text="User Name"
             >
        </asp:Label>
        <asp:TextBox 
             ID="TextBox1" 
             runat="server"
             >
        </asp:TextBox>
        <br /><br />
        <asp:Button 
             ID="Button1" 
             runat="server" 
             ForeColor="Maroon"
             Text="TextBoxMode Password"
             OnClick="Button1_Click"
             Font-Bold="true"
             />
        <asp:Button 
             ID="Button2" 
             runat="server" 
             Font-Bold="true"
             ForeColor="Maroon"
             Text="TextBoxMode SingleLine"
             OnClick="Button2_Click"
             />
    </div>
    </form>
</body>
</html>
Related asp.net example