Idioma

XhtmlTextWriter.OnAttributeRender Método

Definição

Determina se o atributo XHTML especificado e o seu valor podem ser renderizados para o elemento de marcação atual.

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

Parâmetros

name
String

O atributo XHTML para renderizar.

value
String

O valor atribuído ao atributo XHTML.

key
HtmlTextWriterAttribute

O HtmlTextWriterAttribute valor de enumeração associado ao atributo XHTML.

Devoluções

true se o atributo for renderizado na página; caso contrário, false.

Exemplos

O exemplo de código seguinte demonstra como sobrescrever o OnAttributeRender método para verificar se um size atributo é renderizado para algum dos elementos renderizados por este autor do texto. Se um size atributo for renderizado, o código verifica se o seu valor é 8 pontos. Se sim, o OnAttributeRender método devolve true, permitindo que o atributo e o seu valor sejam renderizados. Se o valor for diferente de 8 pontos, o OnAttributeRender método devolve false, e o atributo e o seu valor não são renderizados. Se o parâmetro chave do OnAttributeRender método não corresponder ao Size atributo, a funcionalidade base do OnAttributeRender método é chamada, conforme definido na XhtmlTextWriter classe.

Este exemplo de código faz parte de um exemplo maior fornecido para a XhtmlTextWriter classe.

// Override the OnAttributeRender method to 
// allow this text writer to render only eight-point 
// text size.
protected override bool OnAttributeRender(string name, 
  string value, 
  HtmlTextWriterAttribute key) 
{
    if (key == HtmlTextWriterAttribute.Size)
    {
        if (String.Compare(value, "8pt") == 0)
        {
            return true;
        }
        else
        {
           return false;
        } 
     }
     else
     {
         return base.OnAttributeRender(name, value, key);
     }
 }
' Override the OnAttributeRender method to 
' allow this text writer to render only eight-point 
' text size.
Overrides Protected Function OnAttributeRender(ByVal name As String, _
  ByVal value As String, _
  ByVal key As HtmlTextWriterAttribute _
) As Boolean
   If key = HtmlTextWriterAttribute.Size Then
      If String.Compare(value, "8pt") = 0 Then
         Return True
      Else
         Return False
      End If 
   Else
      Return MyBase.OnAttributeRender(name, value, key)
   End If
End Function

Aplica-se a

Consulte também