This documentation is archived and is not being maintained.
HtmlForm.Name Property
.NET Framework 1.1
Gets the identifier name for the HtmlForm control.
[Visual Basic] Public Overridable Property Name As String [C#] public virtual string Name {get; set;} [C++] public: __property virtual String* get_Name(); public: __property virtual void set_Name(String*); [JScript] public function get Name() : String; public function set Name(String);
Property Value
A string that contains the identifier name for the HtmlForm control.
Remarks
Use this property to identify a specific HtmlForm control.
Note This value is always identical to the UniqueID property.
Example
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script runat="server"> Protected Sub AddButton_Click(sender As Object, e As EventArgs) Dim Answer As Integer ' Calculate and display the result. Answer = Convert.ToInt32(Value1.Value) + Convert.ToInt32(Value2.Value) AnswerMessage.InnerHtml = Answer.ToString() End Sub </script> </head> <body> <form Method="Post" Enctype="application/x-www-form-urlencoded" Name="AddForm" runat="server"> <h3> HtmlInputButton Example </h3> <table> <tr> <td colspan="5"> Enter integer values into the text boxes. <br> Click the Add button to add the two values. <br> Click the Reset button to reset the text boxes. </td> </tr> <tr> <td colspan="5"> </td> </tr> <tr align="center"> <td> <input ID="Value1" Type="Text" Size="2" MaxLength="3" Value="1" runat="server"/> </td> <td> + </td> <td> <input ID="Value2" Type="Text" Size="2" MaxLength="3" Value="1" runat="server"/> </td> <td> = </td> <td> <span ID="AnswerMessage" runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:RequiredFieldValidator ID="Value1RequiredValidator" ControlToValidate="Value1" ErrorMessage="Please enter a value.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value1MinCompareValidator" ControlToValidate="Value1" Operator="LessThan" Type="Integer" ValueToCompare="100" ErrorMessage="Please enter an integer less than 100.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value1MaxCompareValidator" ControlToValidate="Value1" Operator="GreaterThan" Type="Integer" ValueToCompare="0" ErrorMessage="Please enter an integer greater than 0.<br>" Display="Dynamic" runat="server"/> </td> <td colspan="2"> <asp:RequiredFieldValidator ID="Value2RequiredValidator" ControlToValidate="Value2" ErrorMessage="Please enter a value.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value2MinCompareValidator" ControlToValidate="Value2" Operator="LessThan" Type="Integer" ValueToCompare="100" ErrorMessage="Please enter an integer less than 100.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value2MaxCompareValidator" ControlToValidate="Value2" Operator="GreaterThan" Type="Integer" ValueToCompare="0" ErrorMessage="Please enter an integer greater than 0.<br>" Display="Dynamic" runat="server"/> </td> <td>   </td </tr> <tr align="center"> <td colspan="4"> <input Type="Submit" Name="AddButton Value="Add" OnServerClick="AddButton_Click" runat="server"/> <input Type="Reset" Name="AddButton Value="Reset" runat="server"/> </td> <td> </td> </tr> </table> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script runat="server"> protected void AddButton_Click(Object sender, EventArgs e) { int Answer; // Calculate and display the result. Answer = Convert.ToInt32(Value1.Value) + Convert.ToInt32(Value2.Value); AnswerMessage.InnerHtml = Answer.ToString(); } </script> </head> <body> <form Method="Post" Enctype="application/x-www-form-urlencoded" Name="AddForm" runat="server"> <h3> HtmlInputButton Example </h3> <table> <tr> <td colspan="5"> Enter integer values into the text boxes. <br> Click the Add button to add the two values. <br> Click the Reset button to reset the text boxes. </td> </tr> <tr> <td colspan="5"> </td> </tr> <tr align="center"> <td> <input ID="Value1" Type="Text" Size="2" MaxLength="3" Value="1" runat="server"/> </td> <td> + </td> <td> <input ID="Value2" Type="Text" Size="2" MaxLength="3" Value="1" runat="server"/> </td> <td> = </td> <td> <span ID="AnswerMessage" runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:RequiredFieldValidator ID="Value1RequiredValidator" ControlToValidate="Value1" ErrorMessage="Please enter a value.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value1MinCompareValidator" ControlToValidate="Value1" Operator="LessThan" Type="Integer" ValueToCompare="100" ErrorMessage="Please enter an integer less than 100.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value1MaxCompareValidator" ControlToValidate="Value1" Operator="GreaterThan" Type="Integer" ValueToCompare="0" ErrorMessage="Please enter an integer greater than 0.<br>" Display="Dynamic" runat="server"/> </td> <td colspan="2"> <asp:RequiredFieldValidator ID="Value2RequiredValidator" ControlToValidate="Value2" ErrorMessage="Please enter a value.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value2MinCompareValidator" ControlToValidate="Value2" Operator="LessThan" Type="Integer" ValueToCompare="100" ErrorMessage="Please enter an integer less than 100.<br>" Display="Dynamic" runat="server"/> <asp:CompareValidator ID="Value2MaxCompareValidator" ControlToValidate="Value2" Operator="GreaterThan" Type="Integer" ValueToCompare="0" ErrorMessage="Please enter an integer greater than 0.<br>" Display="Dynamic" runat="server"/> </td> <td>   </td </tr> <tr align="center"> <td colspan="4"> <input Type="Submit" Name="AddButton Value="Add" OnServerClick="AddButton_Click" runat="server"/> <input Type="Reset" Name="AddButton Value="Reset" runat="server"/> </td> <td> </td> </tr> </table> </form> </body> </html>
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
HtmlForm Class | HtmlForm Members | System.Web.UI.HtmlControls Namespace
Show: