Bewerken

Share via


HtmlInputText Constructors

Definition

Initializes a new instance of the HtmlInputText class.

Overloads

HtmlInputText()

Initializes a new instance of the HtmlInputText class using default values.

HtmlInputText(String)

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

HtmlInputText()

Initializes a new instance of the HtmlInputText class using default values.

public:
 HtmlInputText();
public HtmlInputText ();
Public Sub New ()

Examples

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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();
         text.Value = "Enter a value.";
         text.MaxLength = 20;
         text.Size = 22;
 
         // Add the control to the Controls collection of the 
         // PlaceHolder control.
         Place.Controls.Clear();
         Place.Controls.Add(text);
         
      }
  
   </script>
  
<head runat="server">
    <title> HtmlInputText Constructor Example </title>
</head>
<body>

   <form id="form1" runat="server">
  
      <h3> HtmlInputText Constructor Example </h3> 
  
      <asp:PlaceHolder id="Place" runat="server"/>
  
   </form>

</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
   <script runat="server" >
  
      Sub Page_Load(sender As Object, e As EventArgs)

         ' Create an HtmlInputText control.
         Dim text As HtmlInputText = New HtmlInputText()
         text.Value = "Enter a value."
         text.MaxLength = 20
         text.Size = 22
 
         ' Add the control to the Controls collection of the 
         ' PlaceHolder control.
         Place.Controls.Clear()
         Place.Controls.Add(text)
         
      End Sub
  
   </script>
  
<head runat="server">
    <title> HtmlInputText Constructor Example </title>
</head>
<body>

   <form id="form1" runat="server">
  
      <h3> HtmlInputText Constructor Example </h3> 
  
      <asp:PlaceHolder id="Place" runat="server"/>
  
   </form>

</body>
</html>

Remarks

Use this constructor to create and initialize a new instance of the HtmlInputText control using default values. It creates a text type text box control.

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

Property Initial Value
Type The "text" literal string.

See also

Applies to

HtmlInputText(String)

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

public:
 HtmlInputText(System::String ^ type);
public HtmlInputText (string type);
new System.Web.UI.HtmlControls.HtmlInputText : string -> System.Web.UI.HtmlControls.HtmlInputText
Public Sub New (type As String)

Parameters

type
String

The type of input control.

Examples

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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.
         Place.Controls.Clear();
         Place.Controls.Add(text);
         
      }

      void Button_Click(Object sender, EventArgs e)
      {

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

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

   <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"
             value="Submit"
             onserverclick="Button_Click" 
             runat="server"/> 
  
   </form>

</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
   <script runat="server" >
  
      Sub Page_Load(sender As Object, e As EventArgs)

         ' Create an HtmlInputText control.
         Dim text As HtmlInputText = New HtmlInputText("password")
         text.MaxLength = 20
         text.Size = 22
 
         ' Add the control to the Controls collection of the 
         ' PlaceHolder control.
         Place.Controls.Clear()
         Place.Controls.Add(text)
         
      End Sub

      Sub Button_Click(sender As Object, e As EventArgs)

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

      End Sub
  
   </script>
  
<head runat="server">
    <title> HtmlInputText Constructor Example </title>
</head>
<body>

   <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"
             value="Submit"
             onserverclick="Button_Click" 
             runat="server"/> 
  
   </form>

</body>
</html>

Remarks

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.

Property Initial Value
Type The value of the type parameter.

Note

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

See also

Applies to