TableCell.CreateControlStyle Method ()


Creates a TableItemStyle for the TableCell control.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

protected override Style CreateControlStyle()

Return Value

Type: System.Web.UI.WebControls.Style

A Style that represents the TableItemStyle for the TableCell control.

The TableItemStyle created by the CreateControlStyle method is used with the Wrap, HorizontalAlign, and VerticalAlign properties.

The CreateControlStyle method is used primarily by control developers extending the functionality of the TableCell control.

The following code example demonstrates how to override the CreateControlStyle method in a custom server control so that it always returns a new instance of the TableStyle class for the TableCell.

<%@ Page Language="C#" %>
<%@ Register TagPrefix="aspSample" 
    Assembly="Samples.AspNet.CS" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<html xmlns="" >
<head id="Head2" runat="server">
    <title>Custom TableCell - CreateControlStyle - C# Example</title>
    <form id="form1" runat="server">

    <h3>Custom TableCell - CreateControlStyle - C# Example</h3>

    <asp:Table id="Table1" runat="server" CellPadding="3" CellSpacing="2">
        <aspSample:CustomTableCellCreateControlStyle Text="(0,0)" />
        <aspSample:CustomTableCellCreateControlStyle Text="(0,1)" />
        <aspSample:CustomTableCellCreateControlStyle Text="(0,2)" />
        <aspSample:CustomTableCellCreateControlStyle Text="(1,0)" />
        <aspSample:CustomTableCellCreateControlStyle Text="(1,1)" />
        <aspSample:CustomTableCellCreateControlStyle Text="(1,2)" />

using System.Web;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
  [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
  public sealed class CustomTableCellCreateControlStyle : System.Web.UI.WebControls.TableCell
    protected override System.Web.UI.WebControls.Style CreateControlStyle()
      // Initializes and return a new instance of the TableStyle class.
      return new System.Web.UI.WebControls.TableStyle(this.ViewState);

.NET Framework
Available since 1.1
Return to top