Create Show Password Check Box In Login Form In ASP.NET Web Forms | ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ShowPasswordCheckBox_Practice.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1{
width:100%;
}
.auto-style2 {
margin-left: 0px;
}
.auto-style3 {
width: 99px;
}
</style>
<script type="text/javascript">
function ShowPassword(checkBox)
{
var PasswordTextBox = document.getElementById("TextBox1");
if (checkBox.checked == true) {
PasswordTextBox.setAttribute("type", "text");
}
else
{
PasswordTextBox.setAttribute("type","password");
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table cellpadding="3" cellspacing="3" class="auto-style1">
<tr>
<td class="auto-style3">PASSWORD</td>
<td>
<asp:TextBox ID="TextBox1" runat="server" TextMode="Password" CssClass="auto-style2" Width="205px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style3"> </td>
<%--<td><input type="checkbox" onchange="document.getElementById('TextBox1').type = this.checked ? 'text' : 'password'"/>Show Password</td>--%>
<td><input type="checkbox" onclick="ShowPassword(this)"/>Show Password</td>
</tr>
</table>
</div>
</form>
</body>
</html>
.png)
.png)
.png)
.png)
.png)
Comments
Post a Comment