Table.AddAttributesToRender Method
.NET Framework 3.0
Adds HTML attributes and styles that need to be rendered to the specified HtmlTextWriter.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
This method is used primarily by control developers to insert the appropriate attributes and styles into the HtmlTextWriter output stream for a Table control. This method overrides WebControl.AddAttributesToRender.
The following code example demonstrates how to override the AddAttributesToRender method in a custom server control to add an attribute to the Table.
<%@ Page Language="VJ#" %>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
<title>Custom Table - AddAttributesToRender - VJ# Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>Custom Table - AddAttributesToRender - VJ# Example</h3>
<aspSample:CustomTableAddAttributesToRender
id="Table1" runat="server"
GridLines="Both" CellPadding="4">
<asp:TableRow>
<asp:TableCell>Row 0, Col 0</asp:TableCell>
<asp:TableCell>Row 0, Col 1</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>Row 1, Col 0</asp:TableCell>
<asp:TableCell>Row 1, Col 1</asp:TableCell>
</asp:TableRow>
</aspSample:CustomTableAddAttributesToRender>
</div>
</form>
</body>
</html>
...
package Samples.AspNet.JSL.Controls;
public class CustomTableAddAttributesToRender
extends System.Web.UI.WebControls.Table
{
protected void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
{
// Add a client-side onclick event to the button.
writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Onclick,
"alert('Hello World');");
// Call the base's AddAttributesToRender method.
super.AddAttributesToRender(writer);
} //AddAttributesToRender
} //CustomTableAddAttributesToRender
Community Additions
ADD
Show: