How to render a password type textbox in ASP.NET

You can render the TextBox control to as password type by setting its TextMode property to Password. The next test .aspx page shows this:

TextBoxAsPassword.aspx

<%@ Page Language=”vb” AutoEventWireup=”false” CodeBehind=”TextBoxAsPassword.aspx.vb”

Inherits=”TextBoxSamplesVB.TextBoxAsPassword” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title>Password type TextBox</title>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

<asp:TextBox ID=”tbPassword” runat=”server” TextMode=”Password”></asp:TextBox>

</div>

</form>

</body>

</html>