Muokkaa

Jaa


ChtmlTextWriter.OnAttributeRender Method

Definition

Determines whether the specified cHTML attribute and its value are rendered to the requesting page. You can override the OnAttributeRender(String, String, HtmlTextWriterAttribute) 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.

protected:
 override bool OnAttributeRender(System::String ^ name, System::String ^ value, System::Web::UI::HtmlTextWriterAttribute key);
protected override bool OnAttributeRender (string name, string value, System.Web.UI.HtmlTextWriterAttribute key);
override this.OnAttributeRender : string * string * System.Web.UI.HtmlTextWriterAttribute -> bool
Protected Overrides Function OnAttributeRender (name As String, value As String, key As HtmlTextWriterAttribute) As Boolean

Parameters

name
String

The cHTML attribute to render.

value
String

The value assigned to name.

key
HtmlTextWriterAttribute

The HtmlTextWriterAttribute associated with name.

Returns

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

Examples

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);
}
' Override the OnAttributeRender method to
' not render the bgcolor attribute, which is 
' not supported in CHTML.
Protected Overrides Function OnAttributeRender(ByVal name As String, ByVal value As String, ByVal key As HtmlTextWriterAttribute) As Boolean
    If (String.Equals("bgcolor", name)) Then
        Return False
    End If

    ' Call the ChtmlTextWriter version of 
    ' the OnAttributeRender method.
    MyBase.OnAttributeRender(name, value, key)

End Function

Remarks

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.

Applies to

See also