top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to show hide password characters in a TextBox in ASP.NET?

+1 vote
1,128 views
How to show hide password characters in a TextBox in ASP.NET?
posted Feb 2, 2016 by Sathyasree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

It is really very easy to show and hide password characters and it has nothing to do with ASP.NET code. It is purely client-side JavaScript code. So I have used jQuery to write this simple piece of code. I have used a CheckBox to show and hide characters in a TextBox but you can use a button if you want and write your code on that button click event.

You need to download jQuery and add into your project. I have my jQuery file in Script folder.

  1. Open Visual Studio 2010
  2. File > New > Website
  3. Visual basic or Visual C# > ASP.NET Web Site
  4. Website > Add New Item > Web Form
  5. Write following tag in between head tag of aspx page
  6. Write code below in between div tag



    Password:










  7. Now add another script tag in between head tag and write code below

    $(function () {
    $("#chkShowPassword").bind("click", function () {
    var txtPassword = $("[id*=txtPassword]");
    if ($(this).is(":checked")) {
    txtPassword.after('');
    txtPassword.hide();
    } else {
    txtPassword.val(txtPassword.next().val());
    txtPassword.next().remove();
    txtPassword.show();
    }
    });
    });
  8. Press F5 and see the result
answer Feb 2, 2016 by Shivaranjini
Similar Questions
+4 votes

I have my Code . Kindly make it correct .

  protected void Button1_Click(object sender, EventArgs e)
  {
        System.Threading.Thread.Sleep(500);
        Image1.ImageUrl = "Below15.png";
        System.Threading.Thread.Sleep(500);
        Image1.ImageUrl = "Below26.png";
        System.Threading.Thread.Sleep(500);
        Image1.ImageUrl = "Below31.png";
        System.Threading.Thread.Sleep(500);
        Image1.ImageUrl = "Below40.png";
        System.Threading.Thread.Sleep(500);
        Image1.ImageUrl = "Above70.png";
 }
...