This documentation is archived and is not being maintained.

ChtmlTextWriter.OnAttributeRender Method

Determines whether the specified cHTML attribute and its value are rendered to the requesting page. You can override the OnAttributeRender method in classes that derive from the ChtmlTextWriter class to filter out attributes that you do not want to render on devices that support cHTML.

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

protected override bool OnAttributeRender(
	string name,
	string value,
	HtmlTextWriterAttribute key


Type: System.String

The cHTML attribute to render.

Type: System.String

The value assigned to name.

Type: System.Web.UI.HtmlTextWriterAttribute

The HtmlTextWriterAttribute associated with name.

Return Value

Type: System.Boolean
true to write the attribute and its value to the ChtmlTextWriter output stream; otherwise, false.

By default, the OnAttributeRender method prevents globally suppressed attributes that are listed in the GlobalSuppressedAttributes property and element-specific, suppressed attributes that are listed in the SuppressedAttributes property from being written to the output stream. You can override the behavior of the OnAttributeRender method in classes that are derived from the ChtmlTextWriter class.

The following code example demonstrates how to use a custom class that overrides the OnAttributeRender method to prevent the bgcolor attribute from being written to the cHTML output stream. It then calls the functionality that is provided by the base OnAttributeRender method from the ChtmlTextWriter class to ensure that its default behavior is used, too.

This code example is part of a larger example provided for the ChtmlTextWriter class.

		// Override the OnAttributeRender method to 
		// not render the bgcolor attribute, which is 
		// not supported in CHTML. 
		protected override bool OnAttributeRender(string name, string value, HtmlTextWriterAttribute key)
			if (String.Equals("bgcolor", name))
				return false;
			// Call the ChtmlTextWriter version of the 
			// the OnAttributeRender method. 
			return base.OnAttributeRender(name, value, key);

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0