New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Show Password Button

Client-side API

RadTextBox provides a built-in ShowPasswordButton for password fields. When enabled, a toggle icon appears inside the input allowing users to reveal or hide the entered password. This demo shows the feature in a practical sign-in form scenario.

Key Features

  • ShowPasswordButton property — set to true to display the toggle icon. Only applies when TextMode is set to Password.
  • get_passwordVisible() / set_passwordVisible(value) — client-side methods for programmatic control of password visibility.
  • Accessibility — the toggle button has proper role="button" and aria-label attributes that update dynamically.
  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.TextBoxExamplesCS.ShowPasswordButton.DefaultCS" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function onSignInClick(sender, args) {
                let passwordBox = $find("<%=PasswordTextBox.ClientID %>");
                let emailBox = $find("<%=EmailTextBox.ClientID %>");
                let email = emailBox.get_value();
                let password = passwordBox.get_value();

                if (!email || !password) {
                    alert("Please enter both email and password.");
                    return;
                }

                alert("Sign in submitted for: " + email);
            }

            function togglePasswordVisibility(sender, args) {
                let passwordBox = $find("<%=PasswordTextBox.ClientID %>");
                let isVisible = passwordBox.get_passwordVisible();
                passwordBox.set_passwordVisible(!isVisible);
                sender.set_text(isVisible ? "Show Password" : "Hide Password");
            }
        </script>
    </telerik:RadCodeBlock>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-narrow">
        <div class="login-card">
            <h2 class="login-title">Sign In</h2>
            <p class="login-subtitle">Log in to your account to continue</p>

            <div class="form-group">
                <label for="EmailTextBox">Email Address</label>
                <telerik:RadTextBox RenderMode="Lightweight" runat="server" ID="EmailTextBox"
                    EmptyMessage="name@example.com" Width="100%">
                </telerik:RadTextBox>
            </div>

            <div class="form-group">
                <label for="ctl00_ContentPlaceholder1_PasswordTextBox">Password</label>

                <telerik:RadTextBox RenderMode="Lightweight" runat="server" ID="PasswordTextBox"
                    TextMode="Password" ShowPasswordButton="true" EmptyMessage="Enter your password" Width="100%">
                </telerik:RadTextBox>
                <span class="form-hint">Use the eye icon to reveal password text</span>
            </div>

            <div class="form-group">
                <qsf:Button ID="SignInButton" runat="server" Text="Sign In" AutoPostBack="false"
                    OnClientClicked="onSignInClick" CssClass="sign-in-button" Width="100%">
                </qsf:Button>
            </div>
        </div>

        <div class="api-section">
            <h3>Client-side API</h3>
            <p class="login-subtitle">Toggle password visibility programmatically using <code>get_passwordVisible()</code> and <code>set_passwordVisible()</code> methods.</p>
            <div class="form-group">
                <qsf:Button ID="ToggleButton" runat="server" Text="Show Password" AutoPostBack="false"
                    OnClientClicked="togglePasswordVisibility">
                </qsf:Button>
            </div>
        </div>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance