HtmlInputText 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 HtmlInputText 類別的新執行個體。
多載
| 名稱 | Description |
|---|---|
| HtmlInputText() |
使用預設值初始化該類別的新實例 HtmlInputText 。 |
| HtmlInputText(String) |
使用指定的輸入控制類型初始化該 HtmlInputText 類別的新實例。 |
HtmlInputText()
使用預設值初始化該類別的新實例 HtmlInputText 。
public:
HtmlInputText();
public HtmlInputText();
Public Sub New ()
範例
<%@ 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>
備註
使用此建構器以預設值建立並初始化新的控制項實例 HtmlInputText 。 它會建立一個 text 文字框的類型控制。
下表顯示了 的 HtmlInputText初始屬性值。
| 房產 | 初始值 |
|---|---|
| Type | 「文字」字串。 |
另請參閱
適用於
HtmlInputText(String)
使用指定的輸入控制類型初始化該 HtmlInputText 類別的新實例。
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)
參數
- type
- String
輸入控制的類型。
範例
<%@ 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>
備註
使用此建構子建立並初始化使用指定的輸入控制類型的新控制實例 HtmlInputText 。 它允許你建立特定類型的文字框控制,例如 password。 目前只 password 支援 or text 類型。 此建構器設計用於允許你在其他文字框類型出現時建立。
下表顯示了 的 HtmlInputText初始屬性值。
| 房產 | 初始值 |
|---|---|
| Type | 參數的 type 值。 |
Note
雖然你可以用這個建構子建立 text 型別文字框控制,但通常還是用無參數建構器代替。