Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP.NET HtmlTable Control

ASP.NET HtmlTable Control


HTML Server Controls HTML Server Controls


Definition and Usage

The HtmlTable control is used to control the

element. In HTML,


property

element is used to create a table.
property Description
Align Specifies the alignment of this table.
Attributes Returns all attribute name and value pairs of the element.
BGColor Specifies the background color of the table.
Border Specifies the width of the border.

Tip:Setting border="0" displays a table without borders!

BorderColor Specifies the color of the border.
CellPadding Specifies the space between the cell border and its content.
CellSpacing Specifies the space between cells.
Disabled A Boolean value that indicates whether the control is disabled. The default is false.
Height Specifies the height of the table.
id The unique id of the control.
InnerHtml Sets or returns the content between the opening and closing tags of this HTML element. Special characters are not automatically converted to HTML entities.
InnerText Sets or returns all text between the opening and closing tags of this HTML element. Special characters are automatically converted to HTML entities.
Rows Returns an HtmlRowCollection object representing all rows in the table.
runat Specifies that this control is a server control. Must be set to "server".
Style Sets or returns the CSS properties applied to this control.
TagName Returns the tag name of the element.
Visible A Boolean value that indicates whether the control is visible.
Width Specifies the width of the table.

Example

HTMLTable
In this example, we declare two HtmlSelect controls, one HtmlInputButton control, and one HtmlTable control in the .aspx file (remember to nest the controls inside the HtmlForm control). The user can choose the number of cells and rows. When the submit button is triggered, the submit subroutine is executed. The submit subroutine generates the table based on the user's input.

HTMLTable 2
In this example, we declare an HtmlTable control and an HtmlInputButton control in the .aspx file (remember to nest the controls inside the HtmlForm control). When the submit button is triggered, the submit subroutine is executed. The submit subroutine modifies the background color and border color of the table, and also modifies the content of the cells.


HTML Server Controls HTML Server Controls