HtmlTextWriter.IsAttributeDefined Método

Definição

Determina se o atributo de marcação especificado e o seu valor são renderizados durante a próxima chamada ao RenderBeginTag método.

Sobrecargas

Name Description
IsAttributeDefined(HtmlTextWriterAttribute)

Determina se o atributo de marcação especificado e o seu valor são renderizados durante a próxima chamada ao RenderBeginTag método.

IsAttributeDefined(HtmlTextWriterAttribute, String)

Determina se o atributo de marcação especificado e o seu valor são renderizados durante a próxima chamada ao RenderBeginTag método.

IsAttributeDefined(HtmlTextWriterAttribute)

Determina se o atributo de marcação especificado e o seu valor são renderizados durante a próxima chamada ao RenderBeginTag método.

protected:
 bool IsAttributeDefined(System::Web::UI::HtmlTextWriterAttribute key);
protected bool IsAttributeDefined(System.Web.UI.HtmlTextWriterAttribute key);
member this.IsAttributeDefined : System.Web.UI.HtmlTextWriterAttribute -> bool
Protected Function IsAttributeDefined (key As HtmlTextWriterAttribute) As Boolean

Parâmetros

key
HtmlTextWriterAttribute

O HtmlTextWriterAttribute associado ao atributo de marcação.

Devoluções

true se o atributo for renderizado durante a próxima chamada ao RenderBeginTag método; caso contrário, false.

Exemplos

O seguinte exemplo de código mostra como usar um override do RenderBeginTag método numa classe que herda da classe HtmlTextWriter . O RenderBeginTag override verifica se um <font> elemento de marcação será renderizado. Se sim, o override chama o IsAttributeDefined método para verificar se o <font> elemento contém um Size atributo. Se não, o AddAttribute método chama o GetAttributeKey método, que define o Size atributo e define o seu valor para 30pt.

// If the tagKey parameter is set to a <font> element
// but a size attribute is not defined on the element,
// the AddStyleAttribute method adds a size attribute
// and sets it to 30 point.
if ( tagKey == HtmlTextWriterTag::Font )
{
   if (  !IsAttributeDefined( HtmlTextWriterAttribute::Size ) )
   {
      AddAttribute( GetAttributeKey( "size" ), "30pt" );
   }
}
// If the tagKey parameter is set to a <font> element
// but a size attribute is not defined on the element,
// the AddStyleAttribute method adds a size attribute
// and sets it to 30 point. 
if (tagKey == HtmlTextWriterTag.Font)
{
    if (!IsAttributeDefined(HtmlTextWriterAttribute.Size))
    {
        AddAttribute(GetAttributeKey("size"), "30pt");
    }
}
' If the tagKey parameter is set to a <font> element
' but a size attribute is not defined on the element,
' the AddStyleAttribute method adds a size attribute
' and sets it to 30 point. 
If tagKey = HtmlTextWriterTag.Font Then
    If Not IsAttributeDefined(HtmlTextWriterAttribute.Size) Then
        AddAttribute(GetAttributeKey("size"), "30pt")
    End If
End If

Observações

Para obter o valor a atribuir ao HtmlTextWriterAttribute objeto, use a IsAttributeDefined(HtmlTextWriterAttribute, String) sobrecarga em vez desta.

Ver também

Aplica-se a

IsAttributeDefined(HtmlTextWriterAttribute, String)

Determina se o atributo de marcação especificado e o seu valor são renderizados durante a próxima chamada ao RenderBeginTag método.

protected:
 bool IsAttributeDefined(System::Web::UI::HtmlTextWriterAttribute key, [Runtime::InteropServices::Out] System::String ^ % value);
protected bool IsAttributeDefined(System.Web.UI.HtmlTextWriterAttribute key, out string value);
member this.IsAttributeDefined : System.Web.UI.HtmlTextWriterAttribute * string -> bool
Protected Function IsAttributeDefined (key As HtmlTextWriterAttribute, ByRef value As String) As Boolean

Parâmetros

key
HtmlTextWriterAttribute

O HtmlTextWriterAttribute associado ao atributo de marcação.

value
String

O valor atribuído ao atributo.

Devoluções

true se o atributo for renderizado durante a próxima chamada ao RenderBeginTag método; caso contrário, false.

Observações

Se o IsAttributeDefined método devolver true, o valor a atribuir ao HtmlTextWriterAttribute objeto é devolvido no value parâmetro.

Ver também

Aplica-se a