HtmlTextWriter.OnAttributeRender Method

Determines whether the specified markup attribute and its value can be rendered to the current markup element.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

protected:
virtual bool OnAttributeRender (
	String^ name, 
	String^ value, 
	HtmlTextWriterAttribute key
)
protected boolean OnAttributeRender (
	String name, 
	String value, 
	HtmlTextWriterAttribute key
)
protected function OnAttributeRender (
	name : String, 
	value : String, 
	key : HtmlTextWriterAttribute
) : boolean
Not applicable.

Parameters

name

A string containing the name of the attribute to render.

value

A string containing the value that is assigned to the attribute.

key

The HtmlTextWriterAttribute associated with the markup attribute.

Return Value

Always true.

The HtmlTextWriter class implementation of the OnAttributeRender method always returns true. The OnAttributeRender overrides can determine whether an attribute will be rendered to the page.

Notes to Inheritors: If you inherit from the HtmlTextWriter class, you can override the OnAttributeRender method to return false to prevent an attribute from being rendered at all, being rendered on a particular element, or being rendered for a particular markup. For example, if you do not want the object derived from HtmlTextWriter to render the bgcolor attribute to <table> elements, you can override the OnAttributeRender and return false when name passes bgcolor and the TagName property value is table.

The following code example shows how to override the OnAttributeRender method. If a Size attribute is rendered, but the Size value is not 30pt, the OnAttributeRender override calls the AddAttribute method to add a Size attribute and set its value to 30pt.

No code example is currently available or this language may not be supported.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: