Partager via


HTML Server Controls

By default, HTML elements within an ASP.NET file are treated as literal text and are programmatically inaccessible to page developers. To make these elements programmatically accessible, you can indicate that an HTML element should be parsed and treated as a server control by adding a runat="server" attribute.

The unique id attribute allows you to programmatically reference the control. Attributes are used to declare property arguments and event bindings on server control instances.

HTML server controls must reside within a containing <form> tag with the runat="server" attribute.

ASP.NET does not require literal (not dynamic) HTML content to be well formed, but it does require that all HTML elements be properly closed (with either a trailing "/" or a closing tag) and cleanly nested (overlapping tags are not allowed). If HTML elements are not closed properly, ASP.NET will not recognize the element. The element will either be ignored or a compilation error will occur, depending on how the element is formed.

You can create an instance of any Web Forms control in three distinct ways: as an element in an HTML document, in a Rapid Application Development (RAD) environment that allows you to drag controls onto a page, or programmatically in a code declaration block or code-behind file.

In This Section

  • Shared HTML Control Properties
    Describes the properties common to all HTML server controls.
  • HtmlAnchor Control
    Describes the HtmlAnchor control. The HtmlAnchor control allows you to programmatically access the HTML <a> tag on the server.
  • HtmlButton Control
    Describes the HtmlButton control. The HtmlButton control allows you to programmatically access the HTML <button> tag on the server.
  • HtmlForm Control
    Describes the HtmlForm control. The HtmlForm control allows you to programmatically access the HTML <form> tag on the server.
  • HtmlGenericControl
    Describes the HtmlGenericControl control. The HtmlGenericControl class allows you to programmatically access HTML server control tags that are not represented by a specific .NET Framework class, such as <span>, <div>, <body>, and <font>.
  • HtmlImage Control
    Describes the HtmlImage control. The HtmlImage control allows you to programmatically access the HTML <img> tag on the server.
  • HtmlInputButton Control
    Describes the HtmlInputButton control. The HtmlInputButton control allows you to programmatically access the HTML <input type= button>, <input type= submit>, and <input type= reset> tags on the server.
  • HtmlInputCheckBox Control
    Describes the HtmlInputCheckBox control. The HtmlInputCheckBox control allows you to programmatically access the HTML <input type= checkbox> tag on the server.
  • HtmlInputFile Control
    Describes the HtmlInputFile control. The HtmlInputFile control allows you to programmatically access the HTML <input type= file> tag on the server.
  • HtmlInputHidden Control
    Describes the HtmlInputHidden control. The HtmlInputHidden control allows you to programmatically access the HTML <input type=hidden> tag on the server.
  • HtmlInputImage Control
    Describes the HtmlInputImage control. The HtmlInputImage control allows you to programmatically access the HTML <input type= image> tag on the server.
  • HtmlInputRadioButton Control
    Describes the HtmlInputRadioButton control. The HtmlInputRadioButton control allows you to programmatically access the HTML <input type= radio> tag on the server.
  • HtmlInputText Control
    Describes the HtmlInputText control. The HtmlInputText control allows you to programmatically access the HTML <input type= text> and <input type= password> tags on the server.
  • HtmlSelect Control
    Describes the HtmlSelect control. The HtmlSelect control allows you to programmatically access the HTML <select> tag on the server.
  • HtmlTable Control
    Describes the HtmlTable control. The HtmlTable control allows you to programmatically access the HTML <table> tag on the server.
  • HtmlTableCell Control
    Describes the HtmlTableCell control. The HtmlTableCell control allows you to programmatically access the HTML <td> and <th> tags on the server.
  • HtmlTableRow Control
    Describes the HtmlTableRow control. The HtmlTableRow control allows you to programmatically access the HTML <tr> tag on the server.
  • HtmlTextArea Control
    Describes the HtmlTextArea control. The HtmlTextArea control allows you to programmatically access the HTML <textarea> tag on the server.