HtmlTextWriter.IsAttributeDefined Método

Definição

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

Sobrecargas

IsAttributeDefined(HtmlTextWriterAttribute)

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

IsAttributeDefined(HtmlTextWriterAttribute, String)

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

IsAttributeDefined(HtmlTextWriterAttribute)

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

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.

Retornos

Boolean

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

Exemplos

O exemplo de código a seguir mostra como usar uma substituição do RenderBeginTag método em uma classe que herda da HtmlTextWriter classe. A RenderBeginTag substituição verifica se um <font> elemento de marcação será renderizado. Nesse caso, a substituição chama o IsAttributeDefined método para verificar se o <font> elemento contém um Size atributo. Caso contrário, o AddAttribute método chama o GetAttributeKey método, que define o Size atributo e define seu valor como 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

Comentários

Para obter o valor a ser atribuído ao HtmlTextWriterAttribute objeto, use a IsAttributeDefined(HtmlTextWriterAttribute, String) sobrecarga em vez deste.

Confira também

Aplica-se a

IsAttributeDefined(HtmlTextWriterAttribute, String)

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

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.

Retornos

Boolean

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

Comentários

Se o IsAttributeDefined método retornar true, o valor a ser atribuído ao HtmlTextWriterAttribute objeto será retornado no value parâmetro.

Confira também

Aplica-se a