System.Web.UI.HtmlControls Namespace HtmlTable Class
Sets or retrieves the cell spacing, in pixels, for an HtmlTable control.
Inline |
<table cellspacing = intPixels ... > |
Script |
HtmlTable.CellSpacing [ = intPixels ] |
intPixels |
Integer specifying the amount of space, in pixels, between adjacent cells in an HtmlTable. |
The property is read/write with no default value.
Use the CellSpacing property to control the spacing between individual cells in the HtmlTable control. The spacing amount specified is added to all four sides of the cell.
All cells in a column share the same cell height and width; therefore, the spacing is applied evenly to all cells in the column. Individual cell sizes cannot be specified.
The following example shows how to declaratively set the CellSpacing property of an HtmlTable control at design time.
<table cellspacing=5 width="92%" runat="server">
<tr>
<th>Table header</th></tr>
<tr>
<td>Table data</td></tr>
</table>
The example below demonstrates how to programmatically set the CellSpacing property at run time, depending on user input.
void Page_Load ( object Source, EventArgs e ) {
if ( !IsPostBack ) {
for ( int i=0; i<=30; i+=5 ) {
spacingSelect.Items.Add ( i.ToString ( ) );
}
spacingSelect.Value = "5";
}
myTable.CellSpacing = int.Parse ( spacingSelect.Value );
}
Show me
HtmlTable Members CellPadding