HtmlInputReset 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 HtmlInputReset 類別的新執行個體。
多載
HtmlInputReset() |
使用預設值,初始化 HtmlInputReset 類別的新執行個體。 |
HtmlInputReset(String) |
使用指定的輸入型別,初始化 HtmlInputReset 類別的新執行個體。 |
HtmlInputReset()
使用預設值,初始化 HtmlInputReset 類別的新執行個體。
public:
HtmlInputReset();
public HtmlInputReset ();
Public Sub New ()
範例
下列程式碼範例示範如何使用 HtmlInputReset 控制項來重設網頁表單的值。
<%@ 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)
{
// Define an HtmlInputReset button using the default constructor.
HtmlInputReset reset1 = new HtmlInputReset();
reset1.ID = "ResetButton1";
reset1.Value = "Reset 1";
// Define an HtmlInputReset button as type "reset".
HtmlInputReset reset2 = new HtmlInputReset("reset");
reset2.ID = "ResetButton2";
reset2.Value = "Reset 2";
// Define an HtmlInputReset button as custom type "custom".
// This is not a valid HTML input type so a standared input
// field will be displayed.
HtmlInputReset reset3 = new HtmlInputReset("custom");
reset3.ID = "ResetButton3";
reset3.Value = "Reset 3";
// Clear the PlaceHolder control and add the Reset buttons to it.
PlaceHolder.Controls.Clear();
PlaceHolder.Controls.Add(reset1);
PlaceHolder.Controls.Add(new LiteralControl("<br />"));
PlaceHolder.Controls.Add(reset2);
PlaceHolder.Controls.Add(new LiteralControl("<br />"));
PlaceHolder.Controls.Add(reset3);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlInputReset Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3> HtmlInputReset Example </h3>
<asp:PlaceHolder id="PlaceHolder"
runat="server">
</asp:PlaceHolder>
<br />
Change the text in the input field and then click
"Reset 1" or "Reset 2" to change it back to its initial
value.
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
' Define an HtmlInputReset button using the default constructor.
Dim reset1 As New HtmlInputReset()
reset1.ID = "ResetButton1"
reset1.Value = "Reset 1"
' Define an HtmlInputReset button as type "reset".
Dim reset2 As New HtmlInputReset("reset")
reset2.ID = "ResetButton2"
reset2.Value = "Reset 2"
' Define an HtmlInputReset button as custom type "custom".
' This is not a valid HTML input type so a standared input
' field will be displayed.
Dim reset3 As New HtmlInputReset("custom")
reset3.ID = "ResetButton3"
reset3.Value = "Reset 3"
' Clear the PlaceHolder control and add the Reset buttons to it.
PlaceHolder.Controls.Clear()
PlaceHolder.Controls.Add(reset1)
PlaceHolder.Controls.Add(New LiteralControl("<br />"))
PlaceHolder.Controls.Add(reset2)
PlaceHolder.Controls.Add(New LiteralControl("<br />"))
PlaceHolder.Controls.Add(reset3)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlInputReset Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3> HtmlInputReset Example </h3>
<asp:PlaceHolder id="PlaceHolder"
runat="server">
</asp:PlaceHolder>
<br />
Change the text in the input field and then click
"Reset 1" or "Reset 2" to change it back to its initial
value.
</form>
</body>
</html>
備註
下表顯示 實例 HtmlInputReset 的初始屬性值。
屬性 | 值 |
---|---|
HtmlControl.TagName | 「reset」 常值字串。 |
適用於
HtmlInputReset(String)
使用指定的輸入型別,初始化 HtmlInputReset 類別的新執行個體。
public:
HtmlInputReset(System::String ^ type);
public HtmlInputReset (string type);
new System.Web.UI.HtmlControls.HtmlInputReset : string -> System.Web.UI.HtmlControls.HtmlInputReset
Public Sub New (type As String)
參數
- type
- String
輸入類型。
範例
下列程式碼範例示範如何使用 HtmlInputReset 控制項來重設網頁表單的值。
<%@ 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)
{
// Define an HtmlInputReset button using the default constructor.
HtmlInputReset reset1 = new HtmlInputReset();
reset1.ID = "ResetButton1";
reset1.Value = "Reset 1";
// Define an HtmlInputReset button as type "reset".
HtmlInputReset reset2 = new HtmlInputReset("reset");
reset2.ID = "ResetButton2";
reset2.Value = "Reset 2";
// Define an HtmlInputReset button as custom type "custom".
// This is not a valid HTML input type so a standared input
// field will be displayed.
HtmlInputReset reset3 = new HtmlInputReset("custom");
reset3.ID = "ResetButton3";
reset3.Value = "Reset 3";
// Clear the PlaceHolder control and add the Reset buttons to it.
PlaceHolder.Controls.Clear();
PlaceHolder.Controls.Add(reset1);
PlaceHolder.Controls.Add(new LiteralControl("<br />"));
PlaceHolder.Controls.Add(reset2);
PlaceHolder.Controls.Add(new LiteralControl("<br />"));
PlaceHolder.Controls.Add(reset3);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlInputReset Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3> HtmlInputReset Example </h3>
<asp:PlaceHolder id="PlaceHolder"
runat="server">
</asp:PlaceHolder>
<br />
Change the text in the input field and then click
"Reset 1" or "Reset 2" to change it back to its initial
value.
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
' Define an HtmlInputReset button using the default constructor.
Dim reset1 As New HtmlInputReset()
reset1.ID = "ResetButton1"
reset1.Value = "Reset 1"
' Define an HtmlInputReset button as type "reset".
Dim reset2 As New HtmlInputReset("reset")
reset2.ID = "ResetButton2"
reset2.Value = "Reset 2"
' Define an HtmlInputReset button as custom type "custom".
' This is not a valid HTML input type so a standared input
' field will be displayed.
Dim reset3 As New HtmlInputReset("custom")
reset3.ID = "ResetButton3"
reset3.Value = "Reset 3"
' Clear the PlaceHolder control and add the Reset buttons to it.
PlaceHolder.Controls.Clear()
PlaceHolder.Controls.Add(reset1)
PlaceHolder.Controls.Add(New LiteralControl("<br />"))
PlaceHolder.Controls.Add(reset2)
PlaceHolder.Controls.Add(New LiteralControl("<br />"))
PlaceHolder.Controls.Add(reset3)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlInputReset Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3> HtmlInputReset Example </h3>
<asp:PlaceHolder id="PlaceHolder"
runat="server">
</asp:PlaceHolder>
<br />
Change the text in the input field and then click
"Reset 1" or "Reset 2" to change it back to its initial
value.
</form>
</body>
</html>
備註
下表顯示 實例 HtmlInputReset 的初始屬性值。
屬性 | 值 |
---|---|
HtmlControl.TagName | type 參數的值。 |
將 type
參數設定為無法辨識為有效 HTML 元素的值,會導致預設 HTML <input>
<input>
元素成為單行文字輸入欄位。