- HTML Table Web Server Control
In ASP.NET environment,This article describes you how to work with HTML Table Control.In
HTML environment, Table is an object that represents a Table in an HTML form. The
Table control in a HTML form contains all instance of an <Table> tag.
The HTML Table contains 3 rows and 3 columns by default when a table control includes
in a page. But we can customize the rows and columns count.
There are several functions available to access the HTML Table.some of its funtions
are as follows,
- document.getElementById()
- document.getElementByName()
HTML Table Objects
- cells[] -Returns an array containing each cell in a table
- rows[] -Returns an array containing each row in a table
- tBodies[] -Returns an array containing each tbody in a table
Table Objects Properties
- id -Sets or returns the id of a Table
- border -Sets or returns the width of the table border
- caption -Sets or returns the caption of a table
- cellPadding -Sets or returns the amount of space between the cell border
and cell content
- cellSpacing -Sets or returns the amount of space between the cells in a table
- frame -Sets or returns the outer-borders of a table
- rules -Sets or returns the inner-borders of a table
- summary - Sets or returns a description of a table
- tFoot - Returns the TFoot object of a table
- tHead -Returns the THead object of a table
- width -Sets or returns the width of a table
- title -Sets or returns an element's advisory title
- lang -Sets or returns the language code for an element
- dir -Sets or returns the direction of text
- className -Sets or returns the class attribute of an element
Table Objects Methods
- createCaption() -Creates a caption element for a table
- createTFoot() -Creates an empty tFoot element in a table
- createTHead() -Creates an empty tHead element in a table
- deleteCaption() -Deletes the caption element and its content from a table
- deleteRow() -Deletes a row from a table
- deleteTFoot() -Deletes the tFoot element and its content from a table
- deleteTHead() -Deletes the tHead element and its content from a table
- insertRow() -Inserts a new row in a table
The following code snippets explains you the HTML Table in the web form.
in .aspx.cs page,
-
void Button_Click(Object sender, EventArgs e)
{
tbl1.BgColor = BgColorSelect.Value;
}
-
in .aspx page,
-
<form id="Form2" runat="server">
<h3>HtmlTable Example</h3>
<table id="tbl1"
Border="1"
BorderColor="black"
runat="server">
<tr>
<th>
Column 1
</th>
<th>
Column 2
</th>
<th>
Column 3
</th>
</tr>
<tr>
<td>
Cell 1
</td>
<td>
Cell 2
</td>
<td>
Cell 3
</td>
</tr>
</table>
<hr>
Select the Bgcolor: <br><br>
<select id="BgColorSelect"
runat="server">
<option Value="Red">Yellow</option>
<option Value="Blue">Black</option>
</select>
<input id="Button1" type="button"
value="Generate Table"
OnServerClick ="Button_Click"
runat="server"/>
</form>
-
- Related Links
-
021c64bd-5b62-4ab6-8406-aaa411a4c6a8|0|.0