44

I'm trying to create a ASP .NET website that masks the password in a registration page as the user types. I found sites that use windows form but it doesn't work for a ASP .NET website.

So if the user types in a password its masked like this

 *******

Any website or suggestion on how I can get it to work would be great.

0

6 Answers 6

119

To do it the ASP.NET way:

<asp:TextBox ID="txtBox1" TextMode="Password" runat="server" />
20

//in aspx page

<asp:TextBox ID="password" runat="server" TextMode="Password" />

//in MVC cshtml

@Html.Password("password", "", new { id = "password", Textmode = "Password" })
1
  • 1
    Glad that you covered ASP .NET MVC as well. +1.
    – RBT
    Commented Apr 11, 2018 at 5:48
5

Use the password input type.

<input type="password" name="password" />

Here is a simple demo http://jsfiddle.net/cPaEN/

3

@JohnHartsock: You can also write type="password". It's acceptable in aspx.

<asp:TextBox ID="txtBox" type="password" runat="server"/>
1
  • This is great but I always have this OCD... where the property casename has to be how it's in ASP.NET format... :P +1 by the way!
    – Si8
    Commented Dec 15, 2020 at 16:37
2

I think this is what you are looking for

 <asp:TextBox ID="txbPass" runat="server" TextMode="Password"></asp:TextBox>
1

Simply select texbox property 'TextMode' and select password...

<asp:TextBox ID="TextBox1" TextMode="Password" runat="server" />

Not the answer you're looking for? Browse other questions tagged or ask your own question.