HtmlInputPassword Constructor
Initializes a new instance of the HtmlInputPassword class using default values.
Assembly: System.Web (in System.Web.dll)
Use this constructor to create and initialize a new instance of the HtmlInputPassword control using default values. It creates a password type text box control.
The following table shows the initial property value for an instance of HtmlInputPassword.
Property | Initial Value |
|---|---|
The "password" literal string. |
The following code example demonstrates how to programmatically add HtmlInputText, HtmlInputPassword, and HtmlInputSubmit controls to a Web Forms page using default constructors to create a simple login screen.
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void page_load(object sender, EventArgs e) { if (IsPostBack) { // Add code to process the Login. } } protected void Page_Init(object sender, EventArgs e) { HtmlInputText userText = new HtmlInputText(); userText.MaxLength = 20; Placeholder1.Controls.Add(userText); HtmlInputPassword passwordText = new HtmlInputPassword(); passwordText.MaxLength = 20; Placeholder2.Controls.Add(passwordText); HtmlInputSubmit submitButton = new HtmlInputSubmit(); submitButton.Value = "Submit"; Placeholder3.Controls.Add(submitButton); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>ASP.NET Example</title> </head> <body> <form id="form1" runat="server"> <table cellpadding="2"> <tr> <td>User Name <asp:placeholder runat="server" id="Placeholder1" /> </td></tr> <tr> <td>Password <asp:placeholder runat="server" id="Placeholder2" /> </td></tr> <tr><td><asp:placeholder runat="server" id="Placeholder3" /> </td></tr> </table> </form> </body> </html>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.