Shared HTML Control Properties

As part of the .NET Framework, ASP.NET shares inheritance across namespaces and classes. There are two subsets of HTML controls that share properties from distinct base classes. These subsets are referred to as container controls and input controls.

Any attribute declared on an HTML control is added to the control's Attributes collection and can be manipulated programmatically, just like a property. For example, if you declare a bgcolor attribute on a <body> element, you can programmatically access the attribute and write event handlers to change its value.

Properties Shared by All HTML Controls

Attributes

Gets all attribute name/value pairs expressed on a server control tag within a selected ASP.NET page.

Note

In HTML server controls, manipulating the Attributes collection is the same as manipulating the Control.ViewState property.

Disabled

Gets or sets a value that indicates whether the disabled attribute is included when an HTML control is rendered on the browser. Including this attribute makes the control read-only.

Style

Gets all cascading style sheet (CSS) properties that are applied to a specified HTML server control in an .aspx file.

TagName

Gets the element name of a tag that contains a runat="server" attribute.

Visible

Gets or sets a value that indicates whether the HTML server control is displayed on the page.

Properties Shared by All HTML Input Controls

HTML input controls map to the standard HTML input elements. They include a type attribute that defines the type of input control they render on a Web page.

The HtmlInputText, HtmlInputPassword, HtmlInputButton, HtmlInputSubmit, HtmlInputReset, HtmlInputCheckBox, HtmlInputImage, HtmlInputHidden, HtmlInputFile, and HtmlInputRadioButton controls share the following properties.

Name

Gets or sets a unique identifier name for the HtmlInputControl control.

Value

Gets or sets the value associated with an input control.

Note

The value associated with a control depends on the context of the control. For example, in controls that allow you to enter text, such as the HtmlInputText control, the value is the text entered in the control. In controls that do not allow you to enter text, such as the HtmlInputButton control, the value is the caption displayed in the control. Refer to the specific control for information regarding the context of the Value property.

Type

Gets the type of an HtmlInputControl control. For example, if this property is set to text, the HtmlInputControl control is a text box for data entry.

Properties Shared by All HTML Container Controls

HTML container controls map to HTML elements that are required to have an opening and a closing tag, such as the <select>, <a>, <button>, and <form> elements.

The HtmlTableCell, HtmlTable, HtmlTableRow, HtmlButton, HtmlForm, HtmlAnchor, HtmlGenericControl, HtmlSelect, and HtmlTextArea controls share the following properties.

InnerHtml

Gets or sets the content found between the opening and closing tags of the specified HTML control. The InnerHtml property does not automatically convert special characters to HTML entities. For example, the less than character (<) is not converted to &lt;. This property is commonly used to imbed HTML elements in the container control.

InnerText

Gets or sets all text between the opening and closing tags of the specified HTML control. Unlike the InnerHtml property, the InnerText property automatically converts special characters to HTML entities. For example, the less than character (<) is converted to &lt;. This property is commonly used when you want to display text with special characters, without specifying the HTML entity.

See Also

Reference

HtmlInputControl

HtmlContainerControl

HtmlControl

Other Resources

HTML Server Controls