HtmlTextWriter.IsStyleAttributeDefined Método

Definición

Determina si se representa un atributo de estilo de marcado durante la siguiente llamada al RenderBeginTag método .

Sobrecargas

Nombre Description
IsStyleAttributeDefined(HtmlTextWriterStyle)

Determina si el atributo de estilo de marcado especificado se representa durante la siguiente llamada al RenderBeginTag método .

IsStyleAttributeDefined(HtmlTextWriterStyle, String)

Determina si el atributo de estilo de marcado especificado y su valor se representan durante la siguiente llamada al RenderBeginTag método .

IsStyleAttributeDefined(HtmlTextWriterStyle)

Determina si el atributo de estilo de marcado especificado se representa durante la siguiente llamada al RenderBeginTag método .

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

HtmlTextWriterStyle asociado al atributo .

Devoluciones

true es si el atributo se representará durante la siguiente llamada al RenderBeginTag método; de lo contrario, false.

Ejemplos

En el ejemplo de código siguiente se muestra cómo comprobar si se representa un <label> elemento. Si es así, el IsStyleAttributeDefined método comprueba si se ha definido un Color atributo de estilo en el elemento . Si no se ha definido el Color atributo , el AddStyleAttribute método define el Color atributo y establece su valor reden .

// 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

Comentarios

Para obtener el valor que se representará con el atributo de estilo especificado, use la IsStyleAttributeDefined(HtmlTextWriterStyle, String) sobrecarga del IsStyleAttributeDefined método .

Consulte también

Se aplica a

IsStyleAttributeDefined(HtmlTextWriterStyle, String)

Determina si el atributo de estilo de marcado especificado y su valor se representan durante la siguiente llamada al RenderBeginTag método .

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

HtmlTextWriterStyle asociado al atributo .

value
String

Valor asignado al atributo style.

Devoluciones

true si el atributo y su valor se representarán durante la siguiente llamada al RenderBeginTag método; en caso contrario, false.

Comentarios

Si el IsStyleAttributeDefined método devuelve true, el valor que se va a asignar al HtmlTextWriterStyle atributo se devuelve en el value parámetro .

Consulte también

Se aplica a