Для отображения пароля попробуйте следующий подход на стороне клиента:
.wrapper {
display: inline-block;
position: relative;
}
.reveal-eye {
position: relative;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
position: absolute;
right: 1px;
top: 1px;
bottom: 1px;
z-index: 2;
width: 30px;
background: #fff url(https://dtzbdy9anri2p.cloudfront.net/cache/b55f544d09a0872a74b4427ce1fe18dd78418396/telerik/img/dist/reveal-password.png) 50% 50% no-repeat;
cursor: pointer;
visibility: hidden;
opacity: 0;
transition: opacity .2s ease 0s, visibility 0s linear .2s;
}
.reveal-eye.is-visible {
display: block;
visibility: visible;
opacity: 1;
transition: opacity .2s ease 0s, visibility 0s linear 0s;
}
<div class="wrapper">
<!--<asp:TextBox ID="passwordTextBox" runat="server" TextMode="Password" />-->
<input type="password" id="passwordTextBox" />
</div>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
function checkShowPasswordVisibility() {
var $revealEye = $(this).parent().find(".reveal-eye");
if (this.value) {
$revealEye.addClass("is-visible");
} else {
$revealEye.removeClass("is-visible");
}
}
$(document).ready(function () {
var txtPassword = document.getElementById('passwordTextBox');
var $revealEye = $('<span class="reveal-eye"></span>')
$(txtPassword).parent().append($revealEye);
$(txtPassword).on("keyup", checkShowPasswordVisibility)
$revealEye.on({
mousedown: function () { txtPassword.setAttribute("type", "text") },
mouseup: function () { txtPassword.setAttribute("type", "password") },
mouseout: function () { txtPassword.setAttribute("type", "password") }
});
})
</script>
Пример исходит из: Кнопка ShowPassword для RadTextBox с паролем TextMode
Однако, если вы хотите это сделатьна стороне сервера во время PostBack, вот пример, показывающий, как получить доступ к TextBox при нажатии кнопки Показать / Скрыть:
protected void btnClick_Click(object sender, EventArgs e)
{
Button btn = sender as Button;
TextBox TextBox1 = btn.Parent.FindControl("TextBox1") as TextBox;
TextBox1.TextMode = TextBox1.TextMode == TextBoxMode.Password ? TextBoxMode.SingleLine : TextBoxMode.Password;
}