Export (0) Print
Expand All

HtmlInputText Constructor (String)

Initializes a new instance of the HtmlInputText class using the specified input control type.

Namespace:  System.Web.UI.HtmlControls
Assembly:  System.Web (in System.Web.dll)

public HtmlInputText(
	string type


Type: System.String
The type of input control.

Use this constructor to create and initialize a new instance of the HtmlInputText control using the specified input control type. It allows you to create a specific type of text box control, such as password. Only the password or text type is currently supported. This constructor is designed to allow you to create other text box types if they become available.

The following table shows the initial property value for an instance of HtmlInputText.


Initial Value


The value of the type parameter.


Although you can use this constructor to create a text type text box control, the default constructor is commonly used instead.

<%@ Page Language="C#" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" >
   <script runat="server" >

      void Page_Load(Object sender, EventArgs e)

         // Create an HtmlInputText control.
         HtmlInputText text = new HtmlInputText("password");
         text.MaxLength = 20;
         text.Size = 22;

         // Add the control to the Controls collection of the 
         // PlaceHolder control.


      void Button_Click(Object sender, EventArgs e)

         // Insert secure authentication here.
         // Make sure to use SSL to secure the connection.



<head runat="server">
    <title> HtmlInputText Constructor Example </title>

   <form id="form1" runat="server">

      <h3> HtmlInputText Constructor Example </h3> 

      Enter your password: <br />
      <asp:PlaceHolder id="Place" runat="server"/>

      <br /><br />

      <input type="submit"



.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

© 2014 Microsoft