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.
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 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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>
- How to set, change TextBox border style
- How to set, change TextBox border width
- How to enable, disable TextBox programmatically
- How to set, change TextBox font name
- How to use theme and skin id (SkinID) in TextBox
- How to set, change TextBox read only mode (ReadOnly)
- How to use theme and skin in TextBox
- How to set, change Button border style programmatically
- How to enable, disable Button programmatically