1
我用asp.net登錄控制在直接登錄我的網站的問題是,我想添加一個選項來顯示密碼(而不是星號),但我無法訪問密碼文本框,因此我無法更改其文本模式。添加選項「顯示密碼」,以asp.net登錄控制
任何想法?
我用asp.net登錄控制在直接登錄我的網站的問題是,我想添加一個選項來顯示密碼(而不是星號),但我無法訪問密碼文本框,因此我無法更改其文本模式。添加選項「顯示密碼」,以asp.net登錄控制
任何想法?
LayoutTemplate
可用於登錄控制,您可以完全更改佈局和任何你想要的。這是一個爲我在一個項目中使用的登錄頁面設計的完整版式。
<asp:Login ID="Login1" runat="server">
<LayoutTemplate>
<table>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="Password" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
</td>
<td>
<asp:CheckBox ID="RememberMe" runat="server" CssClass="hint hide" Text="Remember me next time." />
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color: Red;">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="Login1" />
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
onchange="document.getElementById('password').type = this.checked ? 'text' : 'password'"
即使我們可以使用複選框的onclick事件。 Refference code
你能告訴我們爲什麼你想改變默認行爲嗎? –
@Muhammad Akhtar:可能是因爲星號是長密碼的次要PITA,通常在使用電話設備輸入網頁應用程序和皇家PITA時通常不會選擇您認爲您正在輸入的同一封信,因此完全不需要這些密碼。 – NotMe