TEXTBOX PASSWORD MODE
When the TextMode property of an ASP.NET TextBox is set to Password the value set in the Text property will not display at runtime.
While the security reasons are good to not display the masked password value, leaving it unmasked in the source, it is also necessary at times to display the masked value in the TextBox.
Security reasons aside, you can work around this by adding the password value to the control as as Attribute. Since the TextBox renders as an HTML input control, you can set the value attribute easily, just as you would set the Text property.
Html Coding
First Add - Web Form - Select Label & Textbox & Button From ToolBox - Design Username & Password - Change the Id & Go to - Property - TextMode = Password Change
Html Page
Next - F5 Click - Run Program - Enter Username & Password (Hide )
When the TextMode property of an ASP.NET TextBox is set to Password the value set in the Text property will not display at runtime.
While the security reasons are good to not display the masked password value, leaving it unmasked in the source, it is also necessary at times to display the masked value in the TextBox.
Security reasons aside, you can work around this by adding the password value to the control as as Attribute. Since the TextBox renders as an HTML input control, you can set the value attribute easily, just as you would set the Text property.
Html Coding
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr><td>
<asp:Label ID="Label1" runat="server" Text="UserName"></asp:Label>
</td><td>
<asp:TextBox ID="txtUsername" runat="server"></asp:TextBox>
</td></tr>
<tr><td>
<asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>
</td><td>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
</td></tr>
<tr><td colspan ="2">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Login" />
</td></tr>
</table>
</div>
</form>
</body>
</html>
First Add - Web Form - Select Label & Textbox & Button From ToolBox - Design Username & Password - Change the Id & Go to - Property - TextMode = Password Change
Html Page
Next - F5 Click - Run Program - Enter Username & Password (Hide )
0 comments:
Post a Comment