Determines whether the specified XHTML style attribute and its value can be rendered to the current markup element.
Namespace:
System.Web.UI
Assembly:
System.Web (in System.Web.dll)
Visual Basic (Declaration)
Protected Overrides Function OnStyleAttributeRender ( _
name As String, _
value As String, _
key As HtmlTextWriterStyle _
) As Boolean
Dim name As String
Dim value As String
Dim key As HtmlTextWriterStyle
Dim returnValue As Boolean
returnValue = Me.OnStyleAttributeRender(name, _
value, key)
protected override bool OnStyleAttributeRender(
string name,
string value,
HtmlTextWriterStyle key
)
protected:
virtual bool OnStyleAttributeRender(
String^ name,
String^ value,
HtmlTextWriterStyle key
) override
protected override function OnStyleAttributeRender(
name : String,
value : String,
key : HtmlTextWriterStyle
) : boolean
Return Value
Type:
System..::.Boolean
true if the style attribute is rendered; otherwise, false.
The following code example demonstrates how to override the OnStyleAttributeRender method to check whether a Color attribute is being rendered for any of the elements that are rendered by this text writer. If a Color attribute is rendered, the code checks whether its value is purple. If the value is purple, the OnStyleAttributeRender method returns false and the attribute and its value are not rendered. If the Color attribute is set to any other value, the OnStyleAttributeRender method returns true and the attribute and its value are rendered. If the key parameter of the OnAttributeRender method does not match the Color attribute, the base functionality of the OnStyleAttributeRender method is called, as defined in the XhtmlTextWriter class.
This code example is part of a larger example provided for the XhtmlTextWriter class.
' Override the OnStyleAttributeRender
' method to prevent this text writer
' from rendering purple text.
Overrides Protected Function OnStyleAttributeRender(ByVal name As String, _
ByVal value As String, _
ByVal key As HtmlTextWriterStyle _
) As Boolean
If key = HtmlTextWriterStyle.Color Then
If String.Compare(value, "purple") = 0 Then
Return False
Else
Return True
End If
Else
Return MyBase.OnStyleAttributeRender(name, value, key)
End If
End Function
// Override the OnStyleAttributeRender
// method to prevent this text writer
// from rendering purple text.
protected override bool OnStyleAttributeRender(string name,
string value,
HtmlTextWriterStyle key)
{
if (key == HtmlTextWriterStyle.Color)
{
if (String.Compare(value, "purple") == 0)
{
return false;
}
else
{
return true;
}
}
else
{
return base.OnStyleAttributeRender(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
Reference