HtmlTextWriter.IsStyleAttributeDefined Método

Definição

Determina se um atributo de estilo de marcação é renderizado durante a próxima chamada para o método RenderBeginTag.

Sobrecargas

IsStyleAttributeDefined(HtmlTextWriterStyle)

Determina se o atributo de estilo de marcação especificado é renderizado durante a próxima chamada para o método RenderBeginTag.

IsStyleAttributeDefined(HtmlTextWriterStyle, String)

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

IsStyleAttributeDefined(HtmlTextWriterStyle)

Determina se o atributo de estilo de marcação especificado é renderizado durante a próxima chamada para o método RenderBeginTag.

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

Parâmetros

key
HtmlTextWriterStyle

O HtmlTextWriterStyle associado ao atributo.

Retornos

Boolean

true se o atributo será 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 verificar se um <label> elemento está sendo renderizado. Nesse caso, o IsStyleAttributeDefined método verifica se um Color atributo de estilo foi definido no elemento. Se o Color atributo não tiver sido definido, o AddStyleAttribute método definirá o Color atributo e definirá seu valor como red.

// If the markup element being rendered is a Label,
// render the opening tag of a <Font> element before it.
if ( tagKey == HtmlTextWriterTag::Label )
{
   
   // Check whether a Color style attribute is
   // included on the Label. If not, use the
   // AddStyleAttribute and GetStyleName methods to add one
   // and set its value to red.
   if (  !IsStyleAttributeDefined( HtmlTextWriterStyle::Color ) )
   {
      AddStyleAttribute( GetStyleName( HtmlTextWriterStyle::Color ), "red" );
   }
// If the markup element being rendered is a Label,
// render the opening tag of a Font element before it.
if (tagKey == HtmlTextWriterTag.Label)
{
    // Check whether a Color style attribute is 
    // included on the Label. If not, use the
    // AddStyleAttribute and GetStyleName methods to add one
    // and set its value to red.
    if (!IsStyleAttributeDefined(HtmlTextWriterStyle.Color))
    {
        AddStyleAttribute(GetStyleName(HtmlTextWriterStyle.Color), "red");
    }
' If the markup element being rendered is a Label,
' render the opening tag of a Font element before it.
If tagKey = HtmlTextWriterTag.Label Then
    ' Check whether a Color style attribute is 
    ' included on the Label. If not, use the
    ' AddStyleAttribute and GetStyleName methods to add one
    ' and set its value to red.
    If Not IsStyleAttributeDefined(HtmlTextWriterStyle.Color) Then
        AddStyleAttribute(GetStyleName(HtmlTextWriterStyle.Color), "red")
    End If

Comentários

Para obter o valor que será renderizado com o atributo de estilo especificado, use a IsStyleAttributeDefined(HtmlTextWriterStyle, String) sobrecarga do IsStyleAttributeDefined método.

Confira também

Aplica-se a

IsStyleAttributeDefined(HtmlTextWriterStyle, String)

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

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

Parâmetros

key
HtmlTextWriterStyle

O HtmlTextWriterStyle associado ao atributo.

value
String

O valor atribuído ao atributo de estilo.

Retornos

Boolean

true se o atributo e seu valor serão renderizados durante a próxima chamada para o método RenderBeginTag; caso contrário, false.

Comentários

Se o IsStyleAttributeDefined método retornar true, o valor a ser atribuído ao HtmlTextWriterStyle atributo será retornado no value parâmetro.

Confira também

Aplica-se a