The HtmlTable control is used to control a <table> element. In HTML, the <table>
element is used to create a table.
Properties
Property
Description
Align
Specifies the alignment of the table
BGColor
Specifies the background color of the table
Border
Specifies the width of the borders
Tip: Set
border="0" to display tables with no borders!
BorderColor
Specifies the color of the borders
CellPadding
Specifies the space between the cell walls and contents
CellSpacing
Specifies the space between cells
Height
Specifies the height of the table
id
A unique id for the control
InnerHtml
The HTML content of this element
InnerText
The text-only content of this element
Rows
Returns an HtmlRowCollection object which represents all
rows in the table
runat
Specifies that the control is a server control. Must
be set to "server"
Width
Specifies the width of the table
Example 1
In the following example we declare an HtmlTable
control and an HtmlInputButton control in an .aspx file (remember to embed the controls
inside an HtmlForm control). When the submit button is triggered, the submit subroutine is executed. The
submit subroutine modifies the background color and the border color of the
table, it also changes the contents of the cells:
<script runat="server">
Sub submit(sender As Object, e As EventArgs)
dim i,j
t1.BGColor="yellow"
t1.BorderColor="red"
for i=0 To t1.Rows.Count-1
for j=0 To t1.Rows(i).Cells.Count-1
t1.Rows(i).Cells(j).InnerHtml="Row " & i
next
next
End Sub
</script>
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
terms of use and
privacy policy.